This Python program receives an integer n from the user and calculates the result of the expression n + n × n.
This is a simple exercise that reinforces operator precedence in Python, where multiplication is evaluated before addition.
# Get an integer from the user
n = int(input("Enter an integer: "))
# Calculate the expression
result = n + n * n
# Display the result
print("\n--- Result ---")
print("n + n × n =", result)
Enter an integer: 3
--- Result ---
n + n × n = 12
- The input n is received using input() and converted to an integer
- The expression n + n × n is evaluated using Python’s operator precedence rules
- The result is printed using print() with clear labeling