Lab Description: In this lab we had to create a menu using the program we created in Lab # 2 which had an infinite loop previously. However here in this program we had to make a lot of selections while encoding the program.
Lab Experience: There’s isn’t much to say, there was simply a lot of encoding to do, a lot of selections to make in the menu. It was tedious.
Codes:
def plus(x,y):
x=input(“Enter first value “)
y=input(“Enter second value “)
x = int(x)
y = int(y)
print (x+y)
def minus(x,y):
x=input(“Enter minend “)
y=input(“Enter subtrahend “)
x = int(x)
y = int(y)
print(x-y)
def star(x,y):
x=input(“Enter first value “)
y=input(“Enter second value “)
x = int(x)
y = int(y)
print (x*y)
def slash(x,y):
x=input(“Enter dividend “)
y=input(“Enter divisor “)
x = int(x)
y = int(y)
print (x/y)
def modulo(x,y):
x=input(“Enter first value “)
y=input(“Enter second value “)
x = int(x)
y = int(y)
print (x%y)
def comparison(x,y):
x=input(“Enter first value “)
y=input(“Enter second value “)
if x < y:
print (x,”<“,y)
if x > y:
print (x,”>”,y)
if x == y:
print (x,”==”,y)
def exiit():
import sys
sys.exit()
def actualprogram(R=input(“Select a function: Add, Subtract, Multiply, Divide, Remainder, Compare. If you want to exit, type End “)):
R = R.lower()
if R==”add”:
plus(“a”,”b”)
if R==”subtract”:
minus(“a”,”b”)
if R==”multiply”:
star(“a”,”b”)
if R==”divide”:
slash(“a”,”b”)
if R==”remainder”:
modulo(“a”,”b”)
if R==”compare”:
comparison(“a”,”b”)
if R==”end”:
exiit()
actualprogram(R=input(“Which operator “))
actualprogram()
Screenshots: