Lab 3

Description: Use functions such as the while loop function to manipulate numbers. Allow the user add, subtract, multipy, divide, and find the remainder for two numbers. Also, display whether the number resulted from the expression is less, more than, or equal to zero.

Work:

# Al Rivera # Lab 3: Control Flow # Date: 3/7/13 # Session: 9310

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

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

print (‘Enter 6 to find if x is <, >, == y’)

while x>0 and y>0:

#Addition def function_1 (x,y):     result = x+y     print (‘x+y’) #Subtraction def function_2 (x,y):     result = x-y     print (‘x-y’) #Multipliction def function_3 (x,y):     result = x**y     print (‘x**y’) #Division def function_4 (x,y):     result = x/y     print (‘x/y’) #Remainder def function_5 (x,y):     result = x%y     print (‘x%y’) #Less than, greater, or equal to def function_6 (x,y):     result = x, ‘<, >, ==’,y      print (‘Whether’, x, ‘and’, y, ‘is’, result)     print (‘x<y’,’x>y’,’x==y’)

Screen shot: Problem uploading screen shot.