def p(pamount): print(" " * pamount) from time import sleep a = "1" p(100) print("Welcome to my calculator...") p(1) print("Input 'e' or 'exit' into the operation to exit the calculator") sleep(1) p(5) while a == "1" print("Please input your first number... ") num1 = float(input("?: ")) if num1 = int: pass else: print("That was not a number!") break sleep(1) p(100) print("Please enter your operation... ") op = float(input("?: ")) if op == "e" or op == "E" or op == "exit" or op == "Exit" or op == "eXIT": print("EXITING") sleep(0.8) quit() else: pass sleep(1) p(100) print("Please enter your second number... ") if num2 = int: pass else: print("That was not a number!") break num2 = float(input("?: ")) if op == "+": sleep(1) p(100) print(" The sum is: ", num1, op, num2) print("Answer: ", num1 + num2) a = "2" elif op == "-": sleep(1) p(100) print(" The sum is: ", num1, op, num2) print("Answer: ", num1 - num2) a = "2" elif op == "*": sleep(1) p(100) print(" The sum is: ", num1, op, num2) print("Answer: ", num1 * num2) a = "2" elif op == "/": sleep(1) p(100) print("The sum is: ", num1, op, num2) print("Answer: ", num1 / num2) a = "2" else: print("You did not enter a correct operation") p(10) print("Press enter to exit... ") input("") quit()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question