Python Variables Foundation
variables Topic 02 Foundation

Variables = labeled boxes for data

Foundation lesson for variables and data types. Read theory first, then connect it to a real app example.

Picture this: a labeled box

A variable is a name stuck on a value. Use the name later instead of rewriting the value.

Namescore
=
Value10
→
Use laterprint(score)

score = 10 stores 10. print(score) reads the box.

In easy words: What is a variable?

A variable is a named storage box for data. You store a value once and reuse it later by its name.

Diagram — Variables are named boxes

name age = 18 price total = 18.5 text name = "Riya" flag paid = False

Where variables are used

Used to store user input, prices, names, scores, flags, and intermediate calculations in almost every program.

Easy rules

  • = stores a value — read it as “put this into the box named …”
  • Type matters — you can add numbers, not random text + numbers without converting.
  • Names are lowercase_with_underscores in most Python code.
  • Next lessons: add numbers, join names, and compare with True/False.

Real world: food delivery app

item_count = 2 (how many dishes), total = 18.50 (price with tax), customer = "Riya" (text), paid = False (not paid yet). Tap each box below to see how Python stores it.

Memory locker — click a variable

item_count
2
int
total
18.50
float
customer
"Riya"
str
paid
False
bool
int → whole numbers like items in a cart (2 pizzas, not 2.7)
Assignment in one line
1age = 17 # name = value
2name = "Kodin" # text in quotes
3active = True # yes/no

Example Program

1name = "Riya"
2age = 17
3print(name, age)

Variables and Data Types — Topic Quiz

Check understanding

Answer all questions, then click Check answers. Use this before Practice in the editor.

Q1. What is a variable?

Q2. What is the type of 18.5?

Q3. What does `paid = False` store?

Q4. Which is valid Python naming style?

Score: —