Advertisement
_s8

Untitled

_s8
Nov 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import datetime
  2. import random
  3. import time
  4.  
  5.  
  6. points = {}
  7. player_1 = input("Player one: ")
  8. player_2 = input("Player two: ")
  9. points[player_1] = 0
  10. points[player_2] = 0
  11. rounds = int(input("Rounds: "))
  12. while rounds % 2 != 0:
  13.     print("Sorry, you have to give me an even number!")
  14.     rounds = int(input("Rounds: "))
  15. turn = random.randint(0, 1)
  16. for r in range(0, rounds):
  17.     if turn == 0:
  18.         print("It's {}'s turn!".format(player_1))
  19.     else:
  20.         print("It's {}'s turn!".format(player_2))
  21.     time.sleep(0.5)
  22.     print("Get ready..")
  23.     time.sleep(random.randint(1,12))
  24.     then = datetime.datetime.now()
  25.     t = input("GO!! ")
  26.     now = datetime.datetime.now()
  27.     diff = then-now
  28.     reaction_time = round(abs(diff.total_seconds()), 2)
  29.     if turn == 0:
  30.         points[player_1] += reaction_time
  31.         turn += 1
  32.     else:
  33.         points[player_2] += reaction_time
  34.         turn -= 1
  35.     print("Reaction time: {} seconds".format(reaction_time))
  36. winner = min([points[player_1], points[player_2]])
  37. print("The winner is..")
  38. time.sleep(0.5)
  39. print(player_1+"!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement