Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created August 3, 2017 20:38
Show Gist options
  • Save lsparrish/c3359b7779dd97e30e40ab771bd73b0c to your computer and use it in GitHub Desktop.
Save lsparrish/c3359b7779dd97e30e40ab771bd73b0c to your computer and use it in GitHub Desktop.
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