Get better at visually distinguishing between varying length sequences of zeros.
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
""" | |
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