Expressions and Assignment Statements
Expressions and Assignment Statements
x *= 2 # Equivalent to: x = x * 2
print(x) # Output: 30
x -= 10 # Equivalent to: x = x - 10
print(x) # Output: 20
# Printing results
print("Sum:", sum_result)
print("Product:", product_result)
print("Is x greater than y?", is_x_greater)
print("Is x positive and greater than y?", is_x_positive_and_greater)
print("Updated x:", x)
Output:
Sum: 15
Product: 50
Is x greater than y? True
Is x positive and greater than y? True
Updated x: 13
References:
Downey, A. (2020). Think Python: How to think like a computer scientist (2nd ed.). O'Reilly Media.
Tenkanen, H., Heikinheimo, V., & Whipp, D. (2020). Introduction to Python for geographic data analysis.