L1Β·Foundations

πŸ“¦Variables & Types

Names bound to objects in memory.

basicsassignmentintstrfloat

Β§ 1What is a variable?

A variable is a name that refers to an object stored in memory. Python doesn't have 'boxes' holding values β€” it has labels pointing to objects.

Β§ 2Assignment

The = operator binds a name on the left to the object on the right. The same name can be re-bound to any type later.

1x = 42​
2x = "hello" # perfectly legal β€” Python is dynamically typed​

Β§ 3Built-in types

int (whole numbers), float (decimals), str (text), bool (True/False), NoneType (None). Use type(x) to inspect.

Animated step-through

step 1 / 5// Bind name β†’ string object
1name = "Ada"​
2age = 36​
3height = 1.72​
4is_engineer = True​
5print(name, age, height, is_engineer)​
Variables
name→"Ada"

Try it live Β· Python runs in your browser

Loading playground…
ChallengeCreate three variables of different types and print their type().

Checkpoint quiz

Question 1 / 3
What does type(3.14) return?
Next
Numbers & Operators