Lab Description:
In this lab we are supposed to write a program that asks the user to enter two integer numbers x and y, in which the program should have different operations and then it has to display the results back.
This is the 5 operation that the code need.
1- The sum x + y
2- The difference x – y
3- The product x * y
4- The quotient x/y
5- Whether x is less than, equal, or greater than y
Code:
# Diego Soto
# March 5, 2013
# Sec: 9304
import math
x = input(‘enter fist value: ‘)
x1 = float(x)
y = input(‘enter second value: ‘)
y1= float (y)
print (‘press (1) for addition ‘)
print (‘press (2) for substraction’)
print (‘press (3) for multiplication’)
print (‘press (4) for division’)
print (‘press (5) for reminder’)
print (‘press (6) to check if the first value is less than, equal, or greater than the second value’)
c = input(‘select any operation you want’)
if c == 1:
result = x+y
print ‘the sum of’,x,’and’,y, ‘is’,result
elif c == 2:
result = x-y
print ‘answer is =’,x-y,
elif c == 3:
result = x*y
print ‘answer is =’,x*y,
else:
result = x/y
print ‘answer is =’,x/y,
Screenshots: