Level I
Play with simple math
Imagine you have a calculator, it is the same!
Addition
Subtraction
You can use parenthesis as you would do in any mathematical operation. Here are some examples:
NOTE
By the way, did you notice it doesn’t matter if you type 1+2 or 1 + 2? Blank spaces do not matter.
Multiplication
Division
NOTE
The type of 10.5 is ‘float’. This is how decimal numbers are called in Python programming.
You can use % to calculate the remainder of divisions. For example, if you calculate by hand 11 (dividend) divided by 2 (divisor), the result of the division is 5 (quotient), where 1 is the remainder. So, in Python 11%2 will return 1.
Let’s see it with some examples:
Exponents
We can also calculate exponentials with Python. However, you might have seen them using the “^” notation. Something like this 2^5 = 32. In case you don’t remember or you have never seen it, an exponential is just a repeated multiplication such that 2^5 = 2x2x2x2x2. However, Python doesn’t use “^” but “**”. Do not worry! You do not need to remember everything now, you can always google all these notations!
Previous lesson
Play with strings
Next lesson
Play with logic expressions