P Parentheses
E Exponents
MD Multiplication and Division
AS Addition and Subtraction
# addition
integer_x = 1 + 2 # integer_x = 3
integer_x = integer_x + 1 # integer_x = 3 + 1 = 4
integer_x += 1 # integer_x = 4 + 1 = 5
print(integer_x)
# subtraction
integer_x = 5 - 2 # integer_x = 5 - 2 = 3
integer_x = integer_x - 1 # integer_x = 3 - 1 = 2
integer_x -= 1 # integer_x = 2 - 1 = 1
print(integer_x)
# multiplication
integer_x = 1 * 2 # integer_x = 1 * 2 = 2
integer_x = integer_x * 2 # integer_x = 2 * 2 = 4
integer_x *= 2 # integer_x = 4 * 2 = 8
print(integer_x)
# division
integer_x = 8 / 2 # integer_x = 8 / 2 = 4.0
integer_x = integer_x / 2 # integer_x = 4.0 / 2 = 2.0
integer_x /= 2 # integer_x = 2.0 / 2 = 1.0
print(integer_x)
print(type(integer_x))
5
1
8
1.0
<class 'float'>
# quotient
integer_x = 5 // 2 # 5 / 2 = 2 ... 1
print(integer_x)
integer_x = 5
integer_x //= 2
print(integer_x)
# remainder
integer_x = 5 % 2 # 5 / 2 = 2 ... 1
print(integer_x)
integer_x = 5
integer_x %=2
print(integer_x)
2
2
1
1
# exponent
integer_x = 2 ** 3 # integer_x = 2 ^ 3 = 8
print(integer_x)
integer_x = 2
integer_x **= 3
print(integer_x)
8
8