Lab 2

In this lab we ask the user to enter two integer numbers. Then ask the user to make a choice which operation wants to make (addition, subtraction, division, multiply, remainder,  or show if the first number is greater, less than or equal to the second number. after this operation is complete the program should restart and ask the user for the new values. If the user press 0 as his choice the program ends.

# Pedro Flores

# lab 2- control flow

# 02/28/13

# section: 9310

x = float (input(‘please input number x: ‘))

y = float (input(‘please input number y: ‘))

while (x!=0) and (y!=0):

print (‘———————————————————‘)

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 show the numbers remainder’)

print (‘enter 6 to show if x is less than,more than or equal to y’)

print (‘———————————————————‘)

z = int (input(‘enter your selection:’))

 

if z == 1:

z = (x+y)

print(‘the sum of’,x, ‘and’, y, ‘is’, z)

elif z == 2:

z = (x-y)

print (‘the difference of’,x, ‘and’ ,y, ‘is:’, z)

elif z == 3:

z = (x*y)

print (‘the product of’,x, ‘and’,y, ‘is:’, z)

elif z == 4:

z = (x/y)

print (‘the quotient of’,x, ‘and’,y, ‘is:’, z)

elif z == 5:

z = (x%y)

print (‘the remainder of’,x, ‘and’,y, ‘is:’, z)

elif z == 6:

if x<y:

print (‘x is less than y’)

elif x>y:

print (‘x is more than y’)

else:

print (‘x is equal to y’)

else:

print (‘please enter a valid selection’)

print (‘———————————————————‘)

x = float (input(‘please input number x: ‘))

y = float (input(‘please input number y: ‘))