All lessons
📦

Variables & Data Types

Store data in variables and understand basic types.

Basics 15 min +50 XP

Creating variables

A variable is a name that refers to a value. You assign with =.

name = "Aarav"
age = 21
print(name, age)

Common types

int (whole numbers), float (decimals), str (text), bool (True/False). Python detects the type automatically.

pi = 3.14      # float
is_on = True   # bool
city = "Delhi" # str

Type checking

Use type(x) to see what type a value has.

print(type(42))       # <class 'int'>
print(type("hi"))     # <class 'str'>
Meet Python