DEV Community

Cover image for SIMPLE CALCULATOR (python3)
francnstein
francnstein

Posted on

1 1

SIMPLE CALCULATOR (python3)

I will continue to update this as I add more to it, a simple calculator using while loops if elif else statements. I love this example and can't wait to improve it.

You are now using SimpleCalc

print('What would you like to calculate?')

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 "quit" to end the program')
user_input = input(" ")

if user_input == "quit":
    break

elif user_input == "add":
    num1 = float(input('Enter a number: '))
    num2 = float(input('Enter another number: '))
    result = str(num1 + num2)
    print('The answer is ' + result)

elif user_input == "subtract":
    num1 = float(input('Enter a number: '))
    num2 = float(input('Enter another number: '))
    result = str(num1 - num2)
    print('The answer is ' + result)

elif user_input == "divide":
    num1 = float(input('Enter a number: '))
    num2 = float(input('Enter another number: '))
    result = str(num1 / num2)
    print('The answer is ' + result)

else:
    print('Unknown input')

solo learn
FRANCNSTEIN © 2020 | Created 𝗐𝗂𝗍𝗁 ❤

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay