Python lesson 2
Storing Info with Variables
Save names, numbers, and messages in Python. Like labeling boxes!
What is a Variable?
A variable is like a labeled box. You store a value inside and give the box a name. Later, Python opens the box and uses what is inside!
name = "Alex" stores the text: Alex
age = 10 stores the number: 10
name = "Alex"
age = 10
print(name)
print(age)
What Is In The Box Now?
score = 10
score = 25
print(score)
Variables in Action
Click Run to see how Python stores a name in a variable and prints it!
Hint: Click Run! The variable name holds "Alex" and print(name) shows it on screen.
name = "Alex"
print(name)
Store Your Own Info
Change "Alex" to YOUR name and 10 to YOUR age. Click Run to see your own info printed!
Hint: Change "Alex" to your name and 10 to your age, then click Run!
name = "Alex"
age = 10
print(name)
print(age)
Your Character Sheet
Change all three variables. Name, age, and superpower. To your own. Click Run to show your character sheet!
Hint: Change "Alex", 10, and "flying" to your own name, age, and favorite superpower!
name = "Alex"
age = 10
superpower = "flying"
print(name)
print(age)
print(superpower)
What you can do on CodeIt
Run the example, change one part, and use the result to check your understanding before moving to the next lesson.