cshw/py/MoreIfStatements/challenge2.py

32 lines
824 B
Python

# Start of the program
# Prompt the user to enter the first number and convert it to an integer
num1 = int(input("Enter num1: "))
# Prompt the user to enter the second number and convert it to an integer
num2 = int(input("Enter num2: "))
# Calculate the sum of the two numbers
answer = num1 + num2
# Check if the sum is less than 20
if answer < 20:
# If the sum is less than 20, print the sum
print("Output:", answer)
# If the sum is exactly 20
elif answer == 20:
# Print the message indicating the total is 20
print("Output: The total is 20")
# If the sum is greater than 20
else:
# Multiply the sum by 3 as per the flowchart
answer *= 3
# Print the modified answer
print("Output:", answer)
# Print the goodbye message as the final step
print("Output: Goodbye")
# End of the program