Python Refresher - Numbers (1 minute)
- Mathematical operations like addition (+), subtraction (-), multiplication (*), division (/) and exponential (**) can be performed on number in python.
- Python supports operator hierarchy i.e. for example, multiplication is performed before addition and so on.
Returns 18 because 3*4 is performed first and then the addition is performed.
- Python ignores white spaces between numbers and operators.
3 + 3 +3 *4
- Even when a division returns a whole number, Python returns it as a float.
Returns 3.0 and not 3.
- If a mathematic operation is performed using a float number, Python always returns the output as a float number, even if the output is a whole number.
Returns 16.0 and not 16.