Please I am having problems with this calculator code, help me while stating the solutions in withing the code. Thanks a lot | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please I am having problems with this calculator code, help me while stating the solutions in withing the code. Thanks a lot

https://code.sololearn.com/cN8YHUrj72mL/?ref=app

10th Aug 2017, 8:27 AM
Oyelami Oyewale
Oyelami Oyewale - avatar
2 Answers
+ 6
# some improper indentations, wrong keywords, etc. # please compare with original code. # remember to split input into multiple lines, e.g. # add # 1 # 2 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 'quit' to end the program") user_input = input(": ") if user_input == "quit": pass elif user_input == "add": num1 = float(input("gimme a number")) num2 = float(input("gimme another number")) result=str(num1 + num2 ) elif user_input == "subtract": num1=float(input("gimme a number")) num2=float(input("gimme another number")) result=str(num1 - num2 ) elif user_input == "multiply": num1=float(input("gimme a number")) num2=float(input("gimme another number")) result=str(num1 * num2 ) elif user_input == "divide": num1=float(input("gimme a number")) num2=float(input("gimme another number")) result=str(num1 / num2 ) else: result = 'undefined' print("result is" + result )
10th Aug 2017, 8:34 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Thanks for your reply Hasty Rei code didn't run though gave me EOFError for line 19 when I tried to add
10th Aug 2017, 11:06 AM
Oyelami Oyewale
Oyelami Oyewale - avatar