Mathew K Analytics

Lesson 1 · Data analytics zero to hero

Python Variables & Data Types Explained | Data Analytics #1

Welcome to the first video in a full 30-part series taking you from zero to a job-ready data analyst, entirely in Python. This video covers the absolute…

What you'll learn

Data

No separate download needed — the notebook creates or downloads everything it uses.

📓 Full notebook

Download .ipynb

Data Analytics Zero to Hero, Video 1: Variables, Data Types, and Operators#

  • Welcome to the first video in a full 30-part series taking you from zero to a job-ready data analyst, entirely in Python.
  • This video covers the absolute foundation: variables, the core data types, and the operators you'll use in every single video that follows.
  • No prior programming experience needed. Let's jump straight in.

Before You Start#

  • Install Python 3 from python.org (on Windows, check 'Add python.exe to PATH'), then install VS Code from code.visualstudio.com with its Python and Jupyter extensions.
  • Open the Command Palette (Control/Command plus Shift plus P), run 'Create: New Jupyter Notebook', and select your Python interpreter as the kernel.

Part 1: Variables#

age = 28
print(age)
28
age = 29
print(age)
29

Naming Rules#

first_name = 'Ada'
last_name = 'Lovelace'
print(first_name, last_name)
Ada Lovelace

Part 2: Core Data Types#

whole_number = 42
decimal_number = 3.14
text = 'Data Analytics'
is_active = True
print(type(whole_number))
print(type(decimal_number))
print(type(text))
print(type(is_active))
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>

Converting Between Types#

price_text = '19.99'
price_number = float(price_text)
print(price_number)
print(price_number * 2)
print(str(price_number) + ' dollars')
19.99
39.98
19.99 dollars
age_text = str(29)
print(age_text, type(age_text))
29 <class 'str'>

Part 3: Arithmetic Operators#

a = 17
b = 5
print(a + b)
print(a - b)
print(a * b)
print(a / b)
22
12
85
3.4
print(a // b)
print(a % b)
print(a ** 2)
3
2
289

Part 4: Comparison and Logical Operators#

x = 10
y = 20
print(x == y)
print(x != y)
print(x < y)
print(x >= 10)
False
True
True
True
has_ticket = True
has_id = False
print(has_ticket and has_id)
print(has_ticket or has_id)
print(not has_id)
False
True
True

Part 5: Formatting Output with f-strings#

name = 'Priya'
score = 87.456
print(f'{name} scored {score} points')
print(f'{name} scored {score:.1f} points')
Priya scored 87.456 points
Priya scored 87.5 points
revenue = 48213.7
print(f'Total revenue: ${revenue:,.2f}')
Total revenue: $48,213.70

Wrap-Up: What You Learned#

  • Variables: creating them, reassigning them, and Python's snake_case naming convention.
  • The four core data types: int, float, str, and bool, plus converting between them.
  • Arithmetic operators, including floor division and modulo.
  • Comparison operators, which always return a bool, and the and/or/not logical operators.
  • f-strings for embedding variables in text, with precise number formatting.
  • Everything here is the vocabulary the rest of this 30-video series is written in. Subscribe so video two, on control flow, lands in your feed next see you there.

🧠 Test yourself

Pick an answer to check it. Your best score is saved in this browser.

  1. What does print(17 // 5) output?

  2. Which variable name follows Python's recommended naming style?

  3. What type does type(price_text) show for price_text = '19.99'?

  4. What does this code print?

    has_ticket = True
    has_id = False
    print(has_ticket or not has_id)
    
  5. Given revenue = 48213.7, what does print(f'{revenue:,.2f}') show?

💻 Practice exercises

Try each one in the notebook or in your own editor before opening the solution.

  1. Create variables a = 17 and b = 5. Print their sum, the result of normal division, floor division, and the remainder (modulo).

    💡 Hint

    Use +, /, // and %.

    ✅ Show solution
    a = 17
    b = 5
    print(a + b)   # 22
    print(a / b)   # 3.4
    print(a // b)  # 3
    print(a % b)   # 2
    
  2. Convert the text '19.99' to a float, double it, and print a sentence using an f-string that shows the result with 2 decimals, like Double price: $39.98.

    💡 Hint

    Use float() and a format spec like :.2f inside the f-string.

    ✅ Show solution
    price_text = '19.99'
    price = float(price_text)       # text -> number
    double = price * 2
    print(f'Double price: ${double:.2f}')
    
  3. Make variables name = 'Priya', score = 87.456, and passed = score >= 50. Print one line: Priya scored 87.5 points. Passed: True using an f-string and rounding the score to 1 decimal.

    💡 Hint

    Put the comparison in a variable first, then use {score:.1f} in the f-string.

    ✅ Show solution
    name = 'Priya'
    score = 87.456
    passed = score >= 50           # comparison gives a bool
    print(f'{name} scored {score:.1f} points. Passed: {passed}')
    

Found this useful?

All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.