-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuessTimer.py
40 lines (31 loc) · 875 Bytes
/
GuessTimer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import time
from matplotlib import pyplot as np
import getpass
# A game where the User enters a string "password" and then enters the time allowed to guess.
# Then after a countdown, the User gets the specified amount of time to guess the word.
password = getpass.getpass('Password:')
t = float(input("Enter allowed time for guesser: "))
print("3!")
time.sleep(1)
print("2!")
time.sleep(1)
print("1!")
time.sleep(1)
print("Start guessing!!")
start = time.time()
end = time.time()
while True:
#print("{}".format(end-start))
#print("{}".format(end))
a = input("Enter password: ")
end = time.time()
print("Time left: {}".format(int(t-(end-start))))
if (end - start) > t:
print("You ran out of time")
break
elif a == password:
print("Correct!!!")
break
else:
print("Wrong password")
pass