Day 1Day 2Day 3Day 4
๐งฎ
FREE INTERACTIVE NOTES ยท DAY 3 OF 24
Math Powers & Truth Tests ๐งฎ
Bittu the robot is a lightning-fast calculator โ and today he also learns to answer True or False.
1The four everyday powers
๐ค
Bittu: I can do a billion of these per second. Your school calculator is shaking.
๐ฆ
Professor Hoot: Notice 10 / 2 shows 5.0 not 5 โ division always answers with a decimal number (float).
2The three SECRET powers
๐ Imagine 7 slices of pizza and 2 friends:
๐
Py: // = how many whole slices each (3). % = slices left over (1). ** = power: 2**3 means 2ร2ร2 = 8.
3Truth tests: True or False?
Bittu can compare things. The answer is always True or False โ nothing in between:
๐
Bugly: Heheheโฆ remember: = puts something in a box. == asks "are these equal?". Mix them up and I appear!
4Joining tests: and / or / not
๐ข The rollercoaster rule: you can ride if you are 10 or older AND taller than 120 cm. Both must be True!
๐ฆ
Professor Hoot: and = both must be True. or = any one is enough. not = flips the answer.
5Quick quiz! ๐ง
What is 9 % 4?
๐ก 9 shared by 4: two each (that's 8), and 1 left over. % gives the leftover.
What is True and False?
๐ก and needs BOTH to be True. One False spoils the party.
6Your mission ๐
Mission 1: You have โน100. Momos cost โน30 a plate. Use // to find how many plates you can buy, and % for the money left.
Mission 2: Print whether your age is greater than 10 โ let Python answer True or False.
Mission 3: Compute 2**10. That number is famous in computers โ you'll meet it again!