Primitive Types, Arithmetic Expressions, Order of Operations
Primitive Type:
Arithmetic Expression:
Note:
Arithmetic Expression:
Order of Operation:
- 2.1 + 2.2 != 4.3 because Python evaluates to 4.300000000000001. This is due to the binary addition of these values and approximations in the binary values of the equivalent decimal values. Therefore, checking for exact equality is not recommended for values of this type.
- -15 // 10 = -2 because Python use floor operation for Integer division (-1.5 becomes -2)
- 3 * 10 ** 2 = 300. Operators that have the same precedence are applied left to right except for exponentiation. Exponentiation is applied right to left. Exponentiation binds more strongly than multiplication
- 5.0 == 5 is True, 1 == True is True, 0 == False is True, 1.0 == True is true. Python equality is strict by default
Comments
Post a Comment