Lab 3
Lab Description:
This was an interesting lab because we learned how we can create a loop, and break it too(make it finish it self or create a command that makes it close when you press a button)in this lab we created a lot of equations and we let the user chose that equation that he/she is going to use.
Code:
#Franklin Quintuna
#Section 9304
#03/12/13
#LAB 3
print ‘MATH OPERATIONS’
while True:
print ‘press 1 for addition’
print ‘press 2 for substraction’
print ‘press 3 for multiplication’
print ‘press 4 for division’
print ‘press 5 for reminder’
print ‘pres 6 to compare two numbers’
print ‘press 7 to exit’
op = input (‘please select one option ‘)
if op == 7:
print (‘Have a nice day’)
break
x1 = input (‘enter the first value ‘)
y1 = input (‘enter the second value ‘)
x = float (x1)
y = float (y1)
def add(add):
v=x+y
return v
def sub(sub):
v=x-y
return v
def mul(mul):
v=x*y
return v
def div(div):
v=x/y
return v
def rem(rem):
v=x%y
return v
if op == 1:
print’The sum of ‘,x,’and’,y,’is equal to ‘,add(add)
elif op == 2:
print’The Subtraction of ‘,x,’and’,y,’is equal to ‘,sub(sub)
elif op == 3:
print’The product of ‘,x,’and’,y,’is equal to ‘,mul(mul)
elif op == 4:
print’The Division of ‘,x,’and’,y,’is equal to ‘,div(div)
elif op == 5:
print’The Reminder of ‘,x,’and’,y,’is equal to ‘,rem(rem)
else:
if x>y:
print x,’ is great than ‘,y
elif x<y:
print x,’ is less than ‘,y
else:
print x,’ is equal to ‘,y
Screen Shoots: