Created
August 28, 2018 11:33
-
-
Save richardbwest/e041816a07115a6437aa1ed91de55b1e to your computer and use it in GitHub Desktop.
Python Waiting Game Tutorial Code.
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, time,os | |
while True: #infinite loop | |
os.system('cls') # linux - clear | |
print("Welcome to the waiting game!") | |
print("\n\n") | |
print("Instructions\n") | |
print("You will be told to wait a number of seconds.") | |
print("Wait that number of seconds and then press ENTER") | |
print("Are you ready? Press ENTER to start...") | |
input() | |
waitingTime = random.randint(5,10) | |
start = time.time() | |
input("please wait for " + str(waitingTime) + " seconds") | |
end = time.time() | |
elapsed = end - start | |
difference = abs(round(waitingTime - elapsed,2)) | |
print("You were " + str(difference) + " seconds out") | |
if difference < 0.5: | |
print("Well done, you have good time keeping!") | |
elif difference < 1: | |
print("You did okay!!") | |
else: | |
print("You were rubbish!!!!") | |
input("Press ENTER to try again") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment