Lab 03

Description:

This lab is about asking the user to input two numbers and then ask the user which option does she wants to execute. The problem I had the most was ending the program.

Codes:

x = input (‘Enter the first number: ‘)
y = input (‘Enter the second number: ‘)

while x!=7 or y!=7:
print (‘Enter 1 to add the numbers’)
print (‘Enter 2 to subtract the numbers’)
print (‘Enter 3 to multiply the numbers’)
print (‘Enter 4 to divide the numbers’)
print (‘Enter 5 to see the remainder the numbers’)
print (‘Enter 6 to see whether x is less than, equal, or greater than y’)
print (‘Enter 7 to Exit’)

z = input (‘Eneter your selection: ‘)
if z==1:
result = x+y
print ‘the sum of ‘,x,’and’ ,y, ‘ is = ‘,result
elif z ==2:
result = x-y
print ‘the difference of ‘,x,’and’ ,y, ‘is = ‘,result
elif z ==3:
result = x*y
print ‘the product of ‘,x,’and’ ,y, ‘is = ‘,result
elif z ==4:
result = x/y
print ‘the quotient of ‘,x,’and’ ,y, ‘is = ‘,result
elif z ==5:
result = x%y
print ‘the remainder of ‘,x,’and’ ,y, ‘is = ‘,result
elif z ==6:
if x<y:
print (x,”less than”,y)

if x>y:
print (x,”is greater than”,y)

elif x==6:
print (x,”is equal to”, 6)

x = input (‘Enter the first number: ‘)
y = input (‘Enter the second number: ‘)

Screenshots:

lab3