Dashadower
Dashadower

Reputation: 662

Measuring user acting time in python

So I have a script where it measures how fast a person can press the keyboard 100 times. I have used the time module to set the start and the end of the measuring:

import time
import os
start = time.time()
pause() * 100 #defined the definition to os.system("pause")
end = time.time()

How do I make it so python can compare the elapsed time so if the time taken is >20seconds, it performs commands, and if it is equal or less than 20 seconds then preforms other commands?

Upvotes: 0

Views: 58

Answers (1)

Inbar Rose
Inbar Rose

Reputation: 43447

You mean like this?

elapsed_time = end - start

if elapsed_time > 20:
    # code
else:
    # other code

Upvotes: 1

Related Questions