Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python-3 Online

#Simple Calculator
num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
choice = input("Do you want to add, subtract, multiply, or divide? ")
if choice.upper() == "ADD":
 answer = num1 + num2
 print(num1, "+", num2, "=", answer)
elif choice.upper() == "SUBTRACT":
 answer = num1 - num2
 print(num1, "-", num2, "=", answer)
elif choice.upper() == "MULTIPLY":
 answer = num1 * num2
 print(num1, "*", num2, "=", answer)
elif choice.upper() == "DIVIDE":
 answer = num1 / num2
 print(num1, "/", num2, "=", answer)
else:
 print("Invalid input. Sorry!")

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.