Lesson 2: Variables & Basic Data Types

1. What are Variables?

A variable is a named container that stores a value — like a box with a label.

Examples:

age = 25
name = "Alex"
height = 1.78
is_student = True

Rules: letters, numbers, underscore; cannot start with number; case-sensitive.

Exercise 1

Which is a valid variable name?

2. Basic Data Types

Use type() to check:

print(type(42))      # 
print(type(3.14))    # 
print(type("AI"))    # 
print(type(True))    # 

Exercise 2

Which are correct Python variable assignments?

Exercise 3

Create variables and print types:

x = 42
y = 3.14
z = "Machine Learning"
type(x) = 
type(y) = 
type(z) = 

Summary – Lesson 2

Next: operators (math & comparisons).

← Previous Lesson (1) Next Lesson (3) →