Lab 3

The lab 3 was harder because i had to make a menu wit the following options:                                   1- Sum numbers                                                                                                                 2- Subtract numbers                                                                                                                       3- Multiply numbers                                                                                                                 4- Divide numbers                                                                                                           5- Remainder of numbers                                                                                                       6- Compare numbers                                                                                                                       7- Exit                                                                                                                                                   and the program should ask for two integer numbers x and y and perform the selected operation and display the result.

#program to add, subtrac, multiply, divide, print remainder and
#compare two integer values

function=0
while function!=7:
print(‘1. Multiply’)
print(‘2. Division’)
print(‘3. Addition’)
print(‘4. Subtraction’)
print(‘5. Comparison’)
print(‘6. Remainder’)
print(‘7. Exit\n’)
function= input(‘What Function do you want to do?\n’)
if function==’1′:
print(‘Multiplication’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
print(x*y)
print(‘\n’)
elif functions==’2′:
print(‘Division’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
print(x/y)
print(‘\n’)
elif functions==’3′:
print(‘Addition’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
print(x+y)
print(‘\n’)
elif functions==’4′:
print(‘Subtraction’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
print(x-y)
print(‘\n’)
elif functions==’5′:
print(‘Comparison’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
if x<y:
print(x)
print(‘is less than’)
print(y)
elif x>y:
print(x)
print(‘is greater than’)
print(y)
elif x==y:
print(x)
print(‘is equal to’)
print(y)
elif function==’6′:
print(‘Remainder after Division’)
x=int(input(‘What is the first number?\n’))
y=int(input(‘What is the second number?\n’))
print(x, ‘Division by’ ,y, ‘equals’ , x/y, ‘Remainder’ , x%y)

elif function==’7′:
function=7
exit

And the result was:

Capture

 

Leave a Reply

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