Lab 3

For this Lab I defined all of my functions before executing anything. I defined the functions for all the operations first and called them in the function MainMenu so that it was not all cluttered. After defining Mainmenu I asked the user for an input according to my menu and called the appropriate function. After that I called Mainmenu again at the end of the operation functions until the user entered 7 which ended my program.

import math

def Add():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
Sum = X + Y
print’Sum is’
print Sum
def Sub():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
Dif = X – Y
print’Difference is’
print Dif
def Div():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
Div = X / Y
print’Quotient is’
print Div
def Mul():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
Pro = X * Y
print’Product is’
print Pro
def Rem():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
Rem = X%Y
print’Remainder is’
print Rem
def Com():
X = input(‘Enter X value\n’)
Y = input(‘Enter Y value\n’)
if X == Y:
print’X is equal to Y’
else:
print’X is not equal to Y’

def MainMenu():
print’Enter 1 for Addition’
print’Enter 2 for Subtraction’
print’Enter 3 for Division’
print’Enter 4 for Multiplication’
print’Enter 5 for the Remainder’
print’Enter 6 to compare numbers’
print’Enter 7 to end’
o = input(”)
if o == 1:
Add()
MainMenu()
if o == 2:
Sub()
MainMenu()
if o == 3:
Div()
MainMenu()
if o == 4:
Mul()
MainMenu()
if o == 5:
Rem()
MainMenu()
if o == 6:
Com()
MainMenu()
if o == 7:
print’Thank You for using my Program!’

MainMenu()Lab3

Leave a Reply

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