Skip to content

Instantly share code, notes, and snippets.

@richardbwest
Created August 28, 2018 11:33
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 richardbwest/e041816a07115a6437aa1ed91de55b1e to your computer and use it in GitHub Desktop.
Save richardbwest/e041816a07115a6437aa1ed91de55b1e to your computer and use it in GitHub Desktop.
Python Waiting Game Tutorial Code.
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