How do you write a program to assign two integers value in a variable, calculate the sum, and display the output?
# Step 1: Assign two integers to variables
num1 = 10
num2 = 20# Step 2: Calculate the sum
sum_result = num1 + num2# Step 3: Display the output
print(“The sum of”, num1, “and”, num2, “is:”, sum_result)
Explanation:
We first assign two integer values, 10 and 20, to the variables num1 and num2.
Next, we calculate their sum by adding num1 and num2 and store the result in the variable sum_result.
Finally, we use the print() function to display the output, which shows the sum of the two integers.
When you run this program, the output will be:
The sum of 10 and 20 is: 30
coder helper Asked question August 3, 2023