python
The computer is a calculator
Python knows its maths:
| Symbol | Meaning | Example | Result |
|---|---|---|---|
+ | add | 7 + 3 | 10 |
- | subtract | 7 - 3 | 4 |
* | multiply | 7 * 3 | 21 |
/ | divide | 7 / 2 | 3.5 |
// | divide, keep the whole part | 7 // 2 | 3 |
% | remainder of a division | 7 % 2 | 1 |
** | power | 2 ** 10 | 1024 |
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!
seconds_in_a_day: how many seconds are there in one day?seconds_in_a_week: and in a week? (Reuseseconds_in_a_day.)- Print both.
Try it live: type
60 * 60in the terminal at the>>>prompt and press Enter.