Lab 2

Description: Use if, elif, and else functions  to manipulate numbers. Allow the user to 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 #2: Control Flow # 03/8/13 # Session: 9310

import math

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

print (‘Enter 1 to add the numbers’) print (‘Enter 2 to subract the numbers’) print (‘Enter 3 to miltipy the numbers ‘) print (‘Enter 4 to divide the numbers’) print (‘Enter 5 to remainder the numbers ‘) print (‘Enter 6 to greater than or less than or equal to ‘)

z = input (‘Enter 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 else:     if x>y:     elif x<y:     else x==y:         print (‘The value of’), x, (‘and’), y, (‘is:’), result

Snap shot: Unavailable