Skip to content

Instantly share code, notes, and snippets.

@victorslimak1
Created November 10, 2017 08:55
Show Gist options
  • Save victorslimak1/9762ec8f16525e1a6af7ef555d37b5c3 to your computer and use it in GitHub Desktop.
Save victorslimak1/9762ec8f16525e1a6af7ef555d37b5c3 to your computer and use it in GitHub Desktop.
Calculator created by victor_slimak - https://repl.it/OE3c/10
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