hw 20/3/25 11:31 AM
This commit is contained in:
parent
41aa105ca1
commit
d91b49ddcb
3 changed files with 65 additions and 0 deletions
32
py/MoreIfStatements/challenge2.py
Normal file
32
py/MoreIfStatements/challenge2.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# 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
|
Loading…
Add table
Add a link
Reference in a new issue