I would like to know a way to time between two points in a program. In my situation I will ask the user 10 questions and after display the time it took for them to answer the question (example code below). How would i do this through something like import time ?
Example code:
timer.start
question1 = input("What is your favorite game ?")
timer.end
print(timer.time)
^ The timer.x thing is going to be replaced with your suggestions.
To get a time difference in seconds, use the timedelta. total_seconds() methods. Multiply the total seconds by 1000 to get the time difference in milliseconds. Divide the seconds by 60 to get the difference in minutes.
The math. dist() method returns the Euclidean distance between two points (p and q), where p and q are the coordinates of that point.
In Python, we utilize the asterisk operator to repeat a string. This operator is indicated by a “*” sign. This operator iterates the string n (number) of times.
import time
s=time.time()
question1 = input("What is your favorite game ?")
e=time.time()
print(e-s)
time.time()
Returns the time in seconds since the epoch as a floating point number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With