@bossotron13/

Reaction TIme

Python

No description

fork
loading
Files
  • main.py
main.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pymongo
import time
import os
import random
try:
  import dnspython
except ModuleNotFoundError:
  print('')


def msGet1():
  global milisec
  milisec = int(round(time.time() * 1000))
  
def msGet2():
  global milisec1
  milisec1 = int(round(time.time() * 1000))




myclient = pymongo.MongoClient("mongodb+srv://Boss:[email protected]/test?retryWrites=true")



TimesDB = myclient['Reactions']
RTime = TimesDB['Times']

x = random.randrange(3, 7)

un = input('What is your username?\n')
if un == '' or un == ' ':
  print('fix ur name')
  time.sleep(2)
  exit()
os.system('clear')
  
print('Reaction time test, you ready?\nWhen you see the word NOW press enter\n')

time.sleep(x)
msGet1()
Getnow = input('NOW')
msGet2()
Time = (milisec1 - milisec)

if Time <= 90:
  print('You cheated :(')
  exit()

print('your reaction time is %s ms' % Time)
recoredTime = {'Username': un, 'Reaction Time': Time}
insert = RTime.insert_one(recoredTime)