Lab 3

Similar to lab 2, this lab includes a more detailed menu of math asking which operation to choose. The user chooses the operation and inputs the numbers. After displaying the answer the program shows the menu again with options 1-6 being math equations and 7 being to exit.

 

option = True
while option:
option = input(“””
Menu:
1: Addition of Numbers
2: Subtraction of Numbers
3: Multiplication of Numbers
4: Division of Numbers
5: Remainder of Numbers
6: Compare Numbers
7: Exit

Choose operation to perform: “””)
print option
if option == 1:
a = input(“Enter a: “)
b = input(“Enter b: “)
s = a + b
print “a + b = “, s
if option == 2:
a = input(“Enter a: “)
b = input(“Enter b: “)
s = a – b
print “a – b = “, s
if option == 3:
a = input(“Enter a: “)
b = input(“Enter b: “)
s = a * b
print “a * b = “, s
if option == 4:
a = input(“Enter a: “)
b = input(“Enter b: “)
s = a / b
print “a / b = “, s
if option == 5:
a = input(“Enter a: “)
b = input(“Enter b: “)
s = a % b
print “a % b = “, s
if option == 6:
a = input(“Enter a: “)
b = input(“Enter a: “)
s = a > b
print “a > b = “, s
if option == 7:
exit()

 

lab1pic

Leave a Reply

Your email address will not be published. Required fields are marked *