print(10 + 3) # Output: 13
We also have an augmented assignment operator in Python that means incrementing a
variable by a value.
x = 5x += 3 # Output: 8
Operator precedence in Python is similar to math, but we can always use parentheses
to change the order of operations.
x = 10 + 3 * 2 # Output: 16
Multiplication and division have a higher order, so they are evaluated first.
That's why the answer is 16.
x = 10 + print(x) # Output: 11.5
When we print x, we get 11.5.
x += 3print(x) # Output: 14.5
When we run x += 3, we get 14.5 as the result. When we run x == 13, it will store
False in the x variable.
x = 1000 # Output: 1000
We also have an augmented assignment operator in Python that means incrementing a
variable by a value.
x = 5x += 3 # Output: 8
Operator precedence in Python is similar to math, but we can always use parentheses
to change the order of operations.
x = 10 + 3 * 2 # Output: 16
Multiplication and division have a higher order, so they are evaluated first.
That's why the answer is 16.
x = 10 + print(x) # Output: 11.5
When we print x, we get 11.5.
x += 3print(x) # Output: 14.5
When we run x += 3, we get 14.5 as the result. When we run x == 13, it will store
False in the x variable.
x = 1000 # Output: 1000