Calculator | Sololearn: Learn to code for FREE!

+2

Calculator

So my son tried to make a calculator with the help of the lessons, but the playground site isnt taking the inputs that are given. what is the problem? this is a copy of the code: while True: print ("Options:") print ("Enter 'add' to add two numbers") print ("Enter 'subtract' to subtract two numbers") print ("Enter 'multiply' to multiply two numbers ") print("Enter 'divide' to divide two numbers ") print("Enter 'raise' to raise the first number to the second number") print("Enter 'quit' to quit the program") user_input = (": ") if user_input == "quit": break elif user_input == "add": num1 = float(input("Enter a number:")) num2 = float(input("Enter a second number:")) result = str(num1 + num2) print("The aswer is" + result) elif user_input == "subtract": num3 = float(input("Enter a number:")) num4 = float(input("Enter a second number:")) esult = str(num3 - num4) print("The aswer is" + result) elif user_input == "multiply": num5 = float(input("Enter a number:")) num6 = float(input("Enter a second number:")) esult = str(num5 * num6) print("The aswer is" + result) elif user_input == "divide": num7 = float(input("Enter a number:")) num8 = float(input("Enter a second number:")) esult = str(num7 / num8) print("The aswer is" + result) elif user_input == "raise": num9 = float(input("Enter a number:")) num0 = float(input("Enter a second number:")) esult = str(num9 ** num0) print("The aswer is" + result) else: print("Unknown input")

3/14/2017 7:50:48 AM

jonatan ekberg

7 Answers

New Answer

+7

Check line no 9 from top there is no input function for variable user_input

+6

Jonathan do what Meherban Singh said

+3

yo, replace this line :- user_input =(": ") with :- user_input=input(": ")

+1

And what should be the input function? Should i replace or add something?

+1

i am so so confused

0

tnx guys :)

0

Anytime bro