Variables and Types
AvailableLesson 1 of 60 · Syntax · Easy
The big idea
A variable is a name that stores a value so your program can remember it and use it later. In Python, you create a variable by writing a name, an equals sign =, and a value: Python figures out the type of each value for you automatically.
Think of it like this: Think of a variable like a labeled jar: the name on the label is `x`, and the number `5` is what you put inside.
Read the lesson
A variable is a name that stores a value so your program can remember it and use it later.
In Python, you create a variable by writing a name, an equals sign =, and a value:
age = 20 # a whole number (int)
price = 9.99 # a decimal number (float)
name = "Maya" # text (str)
is_open = True # true or false (bool)
Python figures out the type of each value for you automatically. Whole numbers like 20 are called int, decimals like 9.99 are called float, and words inside quotes like "Maya" are called str.
You do not need any extra keywords or semicolons — just write name = value on its own line.
Quick check
In Python, which line stores the number 10 inside a variable named score?
Your challenge
Create a variable named x and set it to 5 (just type x = 5).
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
Similar to javascript.variables-types (85% overlap). Variables & primitive types: compare let/const (JS), auto/int (C++), := (Go), let mut (Rust), and column types (SQL).
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Variables and Types.
Learn this first
Nothing needed - you can start here.