The big idea
Programs need to remember things and make choices. A game remembers your score and decides whether you have won. In Python, we remember things with variables and make choices with selection.
Let's explore
A variable is like a labelled box in the computer's memory. You give it a name and put a value inside. The = sign means "store this value in this box". It does not mean "equals" like in maths.
name = "Priya"
score = 0
score = score + 10
print(name, "has", score, "points")
This prints Priya has 10 points. The line score = score + 10 takes the old value, adds 10, and stores the new value back in the box.
Every value has a data type. "Priya" is a string (str), meaning text, always inside quotes. 10 is an integer (int), a whole number. 3.5 is a float, a number with a decimal point.
Selection means the program chooses which code to run. Python uses if, elif (short for "else if") and else:
temperature = 28
if temperature > 25:
print("Wear a sun hat")
elif temperature > 10:
print("Wear a jacket")
else:
print("Wear a coat")
Python checks each condition from the top. The first one that is True runs, and the rest are skipped. The (the four spaces) shows which lines belong inside each choice.