Last active
May 23, 2016 05:09
-
-
Save chaim1221/f070d12fe2f80cf58888727bd005390e 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 | |
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