A City Tech OpenLab ePortfolio

lab3

lab description:

this lab involve the user to pick two options 1-6 to run the while and 0 to exit. This is done by a while loop. If the user choose one of the available option (1-6) it lead to a certain part of the while loop that is control by if statement, elif, and else.

source code:

def option(f):
print (‘Press 1 for sum, 2 for substration, 3 for multiplication, 4 for divsion, 5 for remainder, 6 for x less then, equal,or greater than y’)
print (‘Enter 0 to quit.’)
option=int(input(‘pick an option ‘ ))
while option !=0:
option=int(input(‘pick an option ‘ ))
print(‘enter: ‘, option)
if option==1:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
z=x +y
print(‘the sum is’, z )
elif option== 2:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
d=x-y
print(‘the difference is ‘, d)
elif option==3:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
d=x*y
print(‘the product is ‘, d)
elif option==4:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
d=x/y
print(‘the quote is ‘, d)
elif option==5:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
d=x%y
print(‘the  is ‘, d)
elif option==6:
x=int(input(‘enter a value for x ‘))
y=int(input(‘enter a value for y ‘))
if x<y:
print(‘the statement of x<y is true’)
else:
print(‘the statement of x<y is false’)
if x>y:
print(‘the statement of x>y is true’)
else:
print(‘the statement of x>y false’)
if x==y:
print(‘the statement of x==y is true’)
else:
print(‘the statement of x==y is false’)

Screenshot from 2013-10-18 19:35:40

Leave a Reply

Your email address will not be published. Required fields are marked *