Skip to content

Instantly share code, notes, and snippets.

@chaim1221
Last active May 23, 2016 05:09
Show Gist options
  • Save chaim1221/f070d12fe2f80cf58888727bd005390e to your computer and use it in GitHub Desktop.
Save chaim1221/f070d12fe2f80cf58888727bd005390e to your computer and use it in GitHub Desktop.
import random
import math
RESULTS = [0,0,0,0,0,0,0,0,0,0,0,0]
def getNumber():
isDecimal = random.randint(0,1) == 1
numberToDisplay = random.randint(0, 100)
if isDecimal:
print ("Here's my number: %d" % numberToDisplay)
else:
# find a way to display as binary
input ("Can you guess what base I'm using,\nand tell me what that is in the opposite base?")
if input == numberToDisplay:
print ("You're good at this.")
return 1
else:
print ("Better luck next time.")
return 0
def main():
print ("Let's play a game:\nGuess whether I'm using decimal or binary,\n")
print ("and write the equivalent number in the opposite base\nwhen prompted.\n")
for x in range (1, 12):
print ("Round %d" % x)
result = getNumber()
print ("Here's the result: %d" % result)
RESULTS[x] = result
print ("Assigned that value to RESULTS[%d]" % x)
#Call the function
main ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment