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?