Python Calculator


I dont understand why this code won’t execute properly:

print("Welcome to the python calculator!")
type = (raw_input("Addition(A), Subtraction(S), Multiplication(M), Division(D), Power(P), Root(R)")).upper()
def input(num1):
    num1 = float(raw_input("Value one"))
    return num1
def otherInput(num2):
      num2 = float(raw_input("Value two"))
      return num2
import math
if type == "A":
    print input(num1)+otherInput(num2)
elif type == "S":
    print input(num1)-otherInput(num2)
elif type == "M":
    print input(num1)*otherInput(num2)
elif type == "D":
    print input(num1)/otherInput(num2)
elif type == "P":
    print input(num1)**otherInput(num2)
elif type == "R":
    print math.sqrt(input(num1))
    print "Error"


Please keep in mind the IDE I am using require brackets for printing


Your IDE doesn’t run code, python does. Python 3 does not have a print statement, it has a function, yes. Right now you’re mixing python 2 and python 3 code, perhaps that’s what you mean by not executing properly (though you haven’t actually described the problem)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.