Introduction
The print function
Variables
Math in Python
12. Adding and subtracting numbers
The input function
Summary

Instruction

Great! Python knows math quite well, too. For instance, it can add (+) or subtract numbers (-):

temp_yesterday = 30
temp_today = 35
temp_difference = temp_today - temp_yesterday
print(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, print the value of total_population.

Stuck? Here's a hint!

Compute the total_population in the following way:

total_population = population_a + population_b