Python maths

<< Previous: SubstringsNext: Python Challenge 2 >>

Maths in Python

Maths in Python is very similar to normal maths. The order of operations still applies. Some symbols might be slightly different than the ones you are used to. You also have to know about modulus and floor division.

Symbol Math operation Description Example
+ Addition Adds numeric values together 4 + 5 is 9
- Minus Subtracts one numeric value from another 8 - 2 is 6
* Multiply Multiplies a numeric value by another numeric value 3 * 4 is 12
/ Division Divides a numeric value by another numeric value 10 / 2 is 5
** Powers of Raises a numeric value to the power of another numeric value 2**3 is 8
% Modulus Divides a numeric value by another numeric value and returns the remainder after doing so 13 % 5 is 3
// Floor division/Integer division Divides a numeric value by another numeric value and returns the whole number part ignoring any remainder 13 // 5 is 2


Knowledge check


Questions:
Correct:

Question text


<< Previous: SubstringsNext: Python Challenge 2 >>

© All materials created by and copyright S.Goff