Introduction
Displaying values
Variables
7. Variables in expressions
The print function
List basics
Summary

Instruction

Great! You can also use variables in expressions, like this:

temp_yesterday = 30
temp_today = 35
temp_difference = temp_today - temp_yesterday
temp_difference

The code above will print 5, which is the difference between temp_today and temp_yesterday.

Exercise

Declare two variables:

  • population_a with a value of 10000,
  • population_b with a value of 5000.

Then, create a variable named total_population that will add the values of population_a and population_b. Finally, show the value of total_population.

Stuck? Here's a hint!

Declare total_population in the following way:

total_population = population_a + population_b