Looks good, only think I would change is use float instead of int.
I was working on something similar, you beat me to it, so here what I had(This isnt finished, but no use in finishing it now )
I was working on something similar, you beat me to it, so here what I had(This isnt finished, but no use in finishing it now )
Code:
class math:
def add(self,a,b): print a + b
def sub(self,a,b): print a - b
def mul(self,a,b): print a * b
def div(self,a,b): print a / b
def slope(self,a,b,c,d): print (a - b) / (c - d)
def triangle(self,b,h): print 0.5*b*h
def rectangle(self,b,h): print b*h
def circle(self,r): print 3.141592*(r*r)
math = math()
def area():
print "1) Triangle"
print "2) Rectangle"
print "3) Trapazoid"
print "4) Rhombus"
print "5) Circle"
e = int(raw_input("What do you want to do?: "))
if e == 1: math.triangle(float(raw_input("Base: ")), float(raw_input("Hight: ")))
elif e == 2: math.rectangle(float(raw_input("Lengh: ")), float(raw_input("Width: ")))
elif e == 5: math.circle(float(raw_input("Radius: ")))
else:
print "Please choose a valid option"
raw_input("Press enter to continue...")
menu()
def slope(): math.slope(float(raw_input("First y: ")),float(raw_input("Second y: ")),float(raw_input("First x: ")),float(raw_input("Second x: ")))
def sim():
print "1) Add"
print "2) Subtract"
print "3) Multiply"
print "4) Divide"
c = int(raw_input("what do you want to do?: "))
if c == 1: math.add(float(raw_input("First Number: ")),float(raw_input("Second Number: ")))
elif c == 2: math.sub(float(raw_input("First Number: ")),float(raw_input("Second Number: ")))
elif c == 3: math.mul(float(raw_input("First Number: ")),float(raw_input("Second Number: ")))
elif c == 4: math.div(float(raw_input("First Number: ")),float(raw_input("Second Number: ")))
else:
print "Please choose a valid option"
raw_input("Press enter to continue...")
menu()
def adv():
print "1) Slope Finder"
print "2) Area Finder"
d = int(raw_input("What do you want to do?: "))
if d == 1: slope()
elif d == 2: area()
else:
print "Please choose a valid option"
raw_input("Press enter to continue...")
menu()
def menu():
print "1) Simple Calculator"
print "2) Advanced calculators"
a = int(raw_input("what do you want to do?: "))
if a == 1: sim()
elif a == 2: adv()
else:
print "Please choose a valid option"
raw_input("Press enter to continue...")
menu()
menu()