Created
March 22, 2018 14:47
-
-
Save duncanmorris/4d83f06e75f2ee8d77af9c85d8d5d752 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 time | |
def wait_random_time(): | |
r = random.random() | |
time.sleep(r*10) | |
def turn_light_on(): | |
print('LIGHT') | |
def button_is_pressed(): | |
ready = input() | |
return True | |
def main(): | |
times = [] | |
for i in range(5): | |
wait_random_time() | |
turn_light_on() | |
start = time.time() | |
if button_is_pressed(): | |
stop = time.time() | |
elapsed = stop - start | |
times.append(elapsed) | |
print('That took {s} seconds'.format(s=elapsed)) | |
print('Get ready for the next one') | |
print('3') | |
time.sleep(1) | |
print('2') | |
time.sleep(1) | |
print('1') | |
time.sleep(1) | |
if __name__ == '__main__': | |
print('Get Ready to test your reactions.') | |
print('To play, just click the button when you see the green light come on.') | |
print('') | |
print('Enter any key when you are ready to start.') | |
ready = input() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment