Created
November 10, 2017 08:55
-
-
Save victorslimak1/9762ec8f16525e1a6af7ef555d37b5c3 to your computer and use it in GitHub Desktop.
Calculator created by victor_slimak - https://repl.it/OE3c/10
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
import random | |
#Variables | |
num1 = 0 | |
num2 = 0 | |
opr = "+" | |
answer = 0 | |
reply = "" | |
replynum= random.randrange(0,4) | |
while True: | |
if replynum == 1: | |
reply=("You messed up") | |
elif replynum == 2: | |
reply=("Write an Operator") | |
elif replynum == 3: | |
reply=("Do it properly") | |
#Getting numbers | |
num1 = float(input("First Number")) | |
opr = input("Write Operator") | |
num2 = float(input("Second Number")) | |
#Working out answer | |
if opr == "+": | |
answer = num1 + num2 | |
elif opr == "-": | |
answer = num1 - num2 | |
elif opr == "*": | |
answer = num1 * num2 | |
elif opr == "/": | |
answer = num1 / num2 | |
else: | |
print(reply) | |
#Output answer | |
print("Answer:" , answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment