Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##
- # Train your hex. Note the adjustable range and step.
- def hexquiz(therange=(0x0,0x100),step=0x20, cheatsheet=0x0):
- """ cheatsheet=0x1 to view answers before taking quiz """
- from random import randrange
- pile = [i for i in range(therange[0x0],therange[0x1],step)]
- if cheatsheet == 0x1:
- hexcheatsheet(therange,step)
- while len(pile) > 0x0:
- answer = pile[randrange(len(pile))]
- print hex(answer)
- guess = int(raw_input(''))
- if guess == answer: # if answer is correct,
- print 'CORRECT' # remove card from pile
- pile.remove(answer)
- elif guess != answer: # if answer is incorrect,
- print 'INCORRECT' # do not remove from pile and
- pile.append(answer) # add an extra copy
- def hexcheatsheet(therange=(0x0,0x100),step=0x10):
- print 'CHEATSHEET:'
- for i in range(therange[0x0],therange[0x1],step):
- print hex(i), '-', i
- print ''
- hexquiz(cheatsheet=0x1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement