Skip to content

Instantly share code, notes, and snippets.

@ehgoodenough
Last active October 10, 2015 17:28
Show Gist options
  • Save ehgoodenough/3725579 to your computer and use it in GitHub Desktop.
Save ehgoodenough/3725579 to your computer and use it in GitHub Desktop.
I've had a bit of difficulty working the equations assigned in digital logic that are designated in base two, so I coded this up to acquaint myself with binary.
import random
while True:
decivalue = random.randrange(0,99)
binavalue = bin(decivalue)[2:]
answer = int(input("What is " + binavalue + " in base ten? "))
if answer == decivalue:
print("..hooray! :D")
else:
print("..try again.. :<")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment