Created
August 3, 2017 20:38
-
-
Save lsparrish/c3359b7779dd97e30e40ab771bd73b0c to your computer and use it in GitHub Desktop.
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,getch | |
i='' | |
def getNum(num): | |
return random.randint(0,num) | |
print 'Hint: The modulus operator "%" is like a clock or dial.' | |
while(i != 'q'): | |
j,k=getNum(9),getNum(9) | |
print str(j)+'+'+str(k)+'\n%10' | |
i=getch.getch() | |
print i | |
if i==(str((j+k)%10)): | |
print "Right" | |
else: | |
if i=='q': | |
break | |
print "Oops - "+str((j+k)%10) | |
print str(j)+'-'+str(k)+'\n%10' | |
i=getch.getch() | |
print i | |
if i==(str((j-k)%10)): | |
print "Right" | |
else: | |
if i=='q': | |
break | |
print "Oops - "+str((j-k)%10) | |
print str(j)+'*'+str(k)+'\n%10' | |
i=getch.getch() | |
print i | |
if i==(str((j*k)%10)): | |
print "Right" | |
else: | |
if i=='q': | |
break | |
print "Oops - "+str((j*k)%10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment