Skip to content

Instantly share code, notes, and snippets.

@kanzure
Created March 19, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanzure/17dd25ddc6c6207c3817 to your computer and use it in GitHub Desktop.
Save kanzure/17dd25ddc6c6207c3817 to your computer and use it in GitHub Desktop.
Get better at visually distinguishing between varying length sequences of zeros.
"""
Small program to help develop the ability to count the number of zeros in a
number very quickly.
An upgrade to this would be the following: Randomly generate a number with
multiple long repeating sequences of integers. Then ask the user for the length
of the longest repeating sequence within the number.
"""
import random
def play_exponent_round():
"""
Interactively query the user for the exponent.
"""
(low, high) = (3, 18)
exponent = random.randrange(low, high)
number = 10**(exponent)
while True:
print("The number is: {}".format(number))
guessed_exponent = raw_input("What's the exponent? ")
if guessed_exponent == str(exponent):
print("Correct!")
break
else:
print("Wrong.")
def main():
"""
Entrypoint.
"""
while True:
play_exponent_round()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment