Variables
A variable is a box with a name written on it. You put information inside, then call it back later by its name:
Inputs (for input())
One value per line — read in order by input().
name = "Aysel" reads like this: “make a box called name, and put the text Aysel inside it”. Here = doesn’t mean “equals” — it means “assign”.
The magic of f-strings
Section titled “The magic of f-strings”The easiest way to use a variable inside a sentence is an f-string. Write f before the quote, and wrap the variable in curly braces:
Inputs (for input())
One value per line — read in order by input().
Python replaces whatever is inside the curly braces {} with the variable’s value. It looks like magic, but it’s real technology. ✨
A box’s contents can change
Section titled “A box’s contents can change”That’s exactly where the name comes from — variable (something that can vary):
Inputs (for input())
One value per line — read in order by input().
score = score + 10 looks odd, but the logic is simple: “take the old value of the score box, add 10, and put the result back in the box”. The score counter in computer games works exactly like this. 🎮
Rules for naming
Section titled “Rules for naming”- No spaces:
my name❌ →my_name✅ (use_instead of a space) - Can’t start with a number:
1score❌ →score1✅ - Uppercase and lowercase matter:
Nameandnameare two different boxes!
Missions
Section titled “Missions”Intro card
+10 XP ✓ CompletedMake the variables name and age (with your own info) and print both of them in one sentence using a single f-string.
Inputs (for input())
One value per line — read in order by input().
Age calculator
+15 XP ✓ CompletedPut your own birth year into the birth_year variable, and have the program calculate and print how old you are (roughly).
Inputs (for input())
One value per line — read in order by input().
Score counter
+15 XP ✓ CompletedBuild a game counter: score starts at zero, grows three times with score = score + 10, and is shown at the end with print.
Inputs (for input())
One value per line — read in order by input().
Next lesson: the program will talk with you — we’ll learn to get information from the user with input(). Continue →