>_Code Club
← All exercises

python

The computer is a calculator

Python knows its maths:

SymbolMeaningExampleResult
+add7 + 310
-subtract7 - 34
*multiply7 * 321
/divide7 / 23.5
//divide, keep the whole part7 // 23
%remainder of a division7 % 21
**power2 ** 101024

You can store results in variables and reuse them:

minutes_in_an_hour = 60
minutes_in_a_day = minutes_in_an_hour * 24
print(minutes_in_a_day)

Your mission

Don't calculate in your head: make Python do it!

  1. seconds_in_a_day: how many seconds are there in one day?
  2. seconds_in_a_week: and in a week? (Reuse seconds_in_a_day.)
  3. Print both.

Try it live: type 60 * 60 in the terminal at the >>> prompt and press Enter.

Next exerciseFunctions →
Loading the editor…