Skip to content

Instantly share code, notes, and snippets.

@amigojapan
Created July 19, 2018 08:41
Show Gist options
  • Save amigojapan/2f0d9d1d694ded5a8e58478468b15d81 to your computer and use it in GitHub Desktop.
Save amigojapan/2f0d9d1d694ded5a8e58478468b15d81 to your computer and use it in GitHub Desktop.
import random
while(True):
operator=random.randint(1,4) ##choose operator
A=random.randint(1,10)
B=random.randint(1,10)
if operator==1: ##addition
result=int(input(str(A)+"+"+str(B)+"="))
if result==A+B:
print("correct!")
if operator==2: ##multiplication
result=int(input(str(A)+"x"+str(B)+"="))
if result==A*B:
print("correct!")
if operator==3: ##substraction
result=int(input(str(A)+"-"+str(B)+"="))
if result==A-B:
print("correct!")
if operator==4: ##addition
result=int(input(str(A)+" divided by "+str(B)+"="))
if result==A/B:
print("correct!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment