LPTHW Exercise 3: Numbers and Math

Learn Python the Hard Way by Zed Shaw .: Order of math operations is PEMDAS: Parentheses Exponents Multiplication Division Addition Subtraction.

So long as at least one of the numbers in a calculation is a floating point number the answer returned will also be floating point. Otherwise:

>>> 5 / 2
2
>>> 5.0 / 2
2.5
>>> 5.0 % 2
1.0
>>>

More • pythonprogramming