import math
print "python calculator"
print "calc or eval"
while 0 == 0:
check = raw_input() #(experimental evaluation or traditional calculator)
if check == "eval":
a = raw_input("operator
") #operator
if a == "+":
b = input("arg1
") #inarg1
c = input("arg2
") #inarg2
z = b + c
print z
elif a == "-":
b = input("arg1
") #inarg1
c = input("arg2") #inarg2
z = b - c
print z
elif a == "/":
b = input("arg1
") #inarg1
c = input("arg2
") #inarg2
z = b / c
print z
elif a == "*":
b = input("arg1
") #inarg1
c = input("arg2]n") #inarg2
z = b * c
print z
elif a == "^":
b = input("arg1
") #inarg1
c = input("arg2
") #inarg2
z = b ** c
elif a == "sin":
b = input("arg1
") #inarg1
var = math.degrees(math.sin(b))
print var
elif a == "asin":
b = input("arg1
") #inarg1
var = math.degrees(math.asin(b))
print var
elif a == "cos":
b = input("arg1
") #inarg1
var = math.degrees(math.cos(b))
print var
elif a == "acos":
b = input("arg1
") #inarg1
var = math.degrees(math.acos(b))
print var
elif a == "tan":
b = input("arg1
") #inarg1
var = math.degrees(math.tan(b))
print var
elif a == "atan":
b = input("arg1
") #inarg1
var = math.degrees(math.atan(b))
print var
elif check == "calc" :
x = input() #takes input as expression
print x #prints expression's result
Isn't the sine of 90 degrees 1? With this it shows up as something around 51.2? Google's calculator does this too? BTW: this is my python calculator
b = input("arg1
") #inarg1
var = math.degrees(math.sin(b))
print var
This one and other trig functions are the problem. For the most part, this was just a simple python calculator, but I wanted to add some trig functions.
See Question&Answers more detail:os