python - cant get exponent to work in my calculator -


this first time doing in python...or other programming language @ really.

below first try @ simple calculator:

print ("hello") def calc():     x = int(input("input first integer: "))     y = int(input("input second integer: "))     type = str.lower(input("(a)dd, (s)ubstract, (m)ultiply, (d)ivide \n"))     if type != "a" , type != "s" , type != "m" , type != "d":         print ("sorry, command entered not valid.")         calc()     else:         if type =="a":             print ("the result '" + str(x+y) + "'")         elif type == "s":             print ("the result '" + str(x-y) + "'")         elif type =="m":             print ("the result '" + str(x*y) + "'")         elif type == "d":             print ("the result '" + str(float(x)/float(y)) + "'")          if int(input("enter 1 if perform calculation? \n")) == 1:             calc()         else:             exit() calc() 

that seems work ok. next tried add exponent , remainder mix , syntax error.

print ("hello") def calc():     x = int(input("input first integer: "))     y = int(input("input second integer: "))     type = str.lower(input("(a)dd, (s)ubstract, (m)ultiply, (d)ivide,       (e)xponent,      (r)emainder\n")) if type != "a" , type != "s" , type != "m" , type != "d" , type != "e" , type != "r":     print ("sorry, command entered not valid.")     calc() else:     if type == "a":         print ("the result '" + str(x+y) + "'")     elif type == "s":         print ("the result '" + str(x-y) + "'")     elif type == "m":         print ("the result '" + str(x*y) + "'")     elif type == "d":         print ("the result '" + str(float(x)/float(y)) + "'")     elif type == "e":         print ("the result '" + str(x**y + "'")     elif type == "r":         print ("the result '" + str(x%y) + "'")      if int(input("enter 1 if perform calculation? \n")) == 1:         calc()     else:         exit() calc() 

is there simple i'm doing incorrectly? also, need add "q" quit...can refer me explain process more simply?

print ("the result '" + str(x**y + "'")

is missing bracket


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -