Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The print function
Variables
10. Undefined variables
Math in Python
The input function
Summary

Instruction

Good. Variables are created when you first assign a value to them. What happens when you try the following?

secret_number = 5
print(random_number)
print(secret_number)

If random_number was never defined before, Python will execute the first line and then show an error. When you get an error, any code that follows the erroneous line will not be executed.

Exercise

Run the template code.

First, the value of the current_age variable is shown. Then, the following error appears:

name 'random_age' is not defined.

Note that the last line

print(current_age)
is never executed because of the error.

Stuck? Here's a hint!

Simply run the template code.