

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Variables
incomplete
2: Variables Vary
incomplete
3: Math
incomplete
4: Negative Numbers
incomplete
5: Comments
incomplete
6: Variable Names
incomplete
7: Basic Variable Types
incomplete
8: F-Strings in Python
incomplete
9: NoneType Variables
incomplete
10: NoneType Quiz
incomplete
11: Dynamic Typing
incomplete
12: Math With Strings
incomplete
13: Multi-Variable Declaration
incomplete
14: Boots
incomplete
15: Spellbook
incomplete
16: Character Report
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Variables store data as our program runs. Up 'til now we've been printing data by passing it straight into print(), but now we'll often save data in variables so we can reuse it and change it before printing it.
A "variable" is just a name that we give to a value:
my_height = 100
Here, we've created a my_height variable and we've set it to 100. We could also create a my_name variable and set it to the string "Lane":
my_name = "Lane"
While variables can be named anything (well, almost anything. You can't have spaces in them), it's best to use descriptive names so you can remember why you created it in the first place!
Once you have a variable, you can access its value by using its name. For example, this prints 100:
print(my_height)
And this prints Lane:
print(my_name)
We need to keep track of our hero's health!
On the first line of code, create a new variable named exactly player_health and set it equal to 1000.