Created
February 15, 2020 18:37
-
-
Save jamiebullock/f60b52fdd45e4a361ab71944b4f27733 to your computer and use it in GitHub Desktop.
Calculator with conditional branching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num1 = input("First Number:\n") | |
operator = input("Operator (+, -, *, /):\n") | |
num2 = input("Second Number:\n") | |
num1 = float(num1) | |
num2 = float(num2) | |
out = None | |
if operator == "+": | |
out = num1 + num2 | |
elif operator == "-": | |
out = num1 - num2 | |
elif operator == "*": | |
out = num1 * num2 | |
elif operator == "/": | |
out = num1 / num2 | |
print("Answer: " + str(out)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment