From 217982eac786709ba1d4689208e256f2c27c02ab Mon Sep 17 00:00:00 2001 From: Brendan Bliss <38093248+brendanbliss@users.noreply.github.com> Date: Thu, 4 Oct 2018 21:07:16 -0600 Subject: [PATCH] Powers of 2 practice game - Brendan Bliss This is a "game" to practice your powers of 2 --- powersof2.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 powersof2.py diff --git a/powersof2.py b/powersof2.py new file mode 100644 index 0000000..02c8020 --- /dev/null +++ b/powersof2.py @@ -0,0 +1,26 @@ +import random + +# I created this as a way to practice powers of 2 for a CS class + +def powerof2(): + + keep_going = True + + userRange = input("What range of powers of 2? ") + userRange = int(userRange) + + while keep_going: + for i in range(userRange): + power = random.randint(0,10) + ans = int(input("What is 2**" + str(power) + ": ")) + correct = 2**power + if ans == correct: + print("Correct!") + else: + print("Wrong!") + print(str(correct)) + keep_going = input("Would you like to play again? (True or False)") + userRange = input("What range of powers of 2? ") + userRange = int(userRange) + +powerof2() \ No newline at end of file