Order of Operations
Python's order of operations works just like math's:
(Remember BOMDAS!)
You've already seen this, actually. The challenge problems at the end of the exponent section asked for these three calculations in a console:
- Parentheses
- Exponents
- Multiplication and division
- Addition and subtraction
(Remember BOMDAS!)
You've already seen this, actually. The challenge problems at the end of the exponent section asked for these three calculations in a console:
The first two raise 16 to the 0.5 power – they take the square root of 16. The second problem first raises 16 to the first power (returning 16) and then divides that by 2, leaving 8.
In programming, just like in math, order of operations matter!
Table 1-1 below shows all the math operators in Python:
In programming, just like in math, order of operations matter!
Table 1-1 below shows all the math operators in Python:
A data type is a category for values, and every value belongs to exactly one data type. The most common data types in Python are listed in Table 1-2 below: