Python Forum

Full Version: Timing input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to find a simple timing snippet to measure response time.

This repeatedly outputs "it took 0.0 seconds." Why?

import time

y = input("What is 4 * 3?")
start = time.time()
if y=="12":
    end = time.time()
    print("it took", (end-start), "seconds")
else: quit()
I don't understand the time class (object?)... I just found it online. Any explanation would help. Thanks!
because the code between the two time calls is done so quickly.
(Oct-23-2019, 08:12 PM)Yoriz Wrote: [ -> ]because the code between the two time calls is done so quickly.

I switched around lines 3 and 4.

Thank you!