Recall from Lesson 1:
Self-Correction on next slide -->
Use arrow keys or buttons to navigate
To learn how to store, label, and retrieve data in the computer's memory bank using Variables.
A Variable is like a labeled box in the computer's memory.
Variables allow the computer to remember things like player scores, health, and names. You give the box a Label and put a Value inside.
To put data into a box, we use the = operator.
In Python, = does NOT mean "equals". It means ASSIGN.
// LIVE DEMO ZONE
TEACHERS: Open the IDE. Model creating two variables `a = 10` and `b = 20`. Then show what happens when you do `a = b`. Does A become 20 or B become 10?
// SPOT THE CRASH
// TEACHER CHECK
Cold-call students to identify the bug in #2 before revealing the tooltip.
"Look inside the box labeled health"
"Literally print the letters h-e-a-l-t-h"
In Python, the + symbol doesn't just add numbers. It can concatenate (join) text together.
Variables can be updated by looking at their current value first.
1. Create three variables:
2. Print all three variables on separate lines.
1. Set hp = 100 and dmg = 25.
2. Update the variable hp so it subtracts the damage.
3. Print a message saying "SYSTEM_UPDATE" then print the new hp.
1. Create first and last name variables.
2. Concatenate them with a space between them.
3. Store the result in a new variable called full_name and print it.
// MISSION PROTOCOL
Complete all 3 tasks in your IDE. Once your terminal matches the logic, signal your status for the Mission Dashboard.
WORKSHEET_SYNC: ACTIVE
Open your Python Worksheet now.
Document all Evidence Codes as you clear each lab sector.
PHASE 1 START
PHASE 1 MID
PHASE 2 START
PHASE 2 MID
PHASE 3 START
PHASE 3 MID
PHASE 4 START
PHASE 4 MID
// SESSION ACTIVE : MINIMISE TALKING //
What is the result of `score = 10` followed by `score = 5`?
The value 5. The 10 is deleted from memory (overwritten).
Why would `player 1 = "John"` fail?
Illegal whitespace. Variables cannot contain spaces.
Difference between `print(age)` and `print("age")`?
The first prints the value in the box; the second prints the string "age" literally.