Case matters, and del
The last line fails on purpose. Read the error from the bottom up: it names the missing variable.
A variable is a name that points to a value, created with =. The name is a label stuck on the value, not a box that holds it: you can move the label to a different value at any time, and two names can point to the same value.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Create length = 8 and width = 5, then a variable area that is their product, and print Area: 40 using the variables.
Set a = 7 and b = 2, swap them in one line, and print both.
Write two variables with names that differ only by capital letters and print them. Explain what this shows.
Explain it without notes
What happens in memory when Python runs price = 30?
Explain why b = a followed by a = 99 leaves b unchanged.
Why is count = count + 1 valid even though it looks impossible in maths?
What are Python's rules for naming a variable, and what is the usual style?
Expected output
Asha Ravi
temp is 5
temp deleted
Traceback (most recent call last):
File "main.py", line 9, in <module>
print(temp)
^^^^
NameError: name 'temp' is not defined