Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Perpetual timing
#1
As another use of a timer, I'm trying to do something like this:
import time

start = time.time()
y = input("What is 4 * 3?")
end = time.time()
while (end-start) < 4:
    if y=="12":
        end = time.time()
        print("it took", (end-start), "seconds")
    else: quit()

start = time.time()
z = input("What is 6 * 6?")
That is, wait until four seconds have elapsed before moving on if not input has been submitted.

Problem is the program stops and waits until input is submitted (when I did enter 12, I saw a running tab of elapsed time until four seconds... pretty cool!).

Is there a way to query continuously whether input has been submitted? If it hasn't then I would have it check time to see if four seconds have passed.
Reply


Messages In This Thread
Perpetual timing - by Mark17 - Oct-23-2019, 08:55 PM
RE: Perpetual timing - by Gribouillis - Oct-23-2019, 09:52 PM
RE: Perpetual timing - by Mark17 - Oct-24-2019, 01:50 PM
RE: Perpetual timing - by Gribouillis - Oct-24-2019, 03:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Timing actions with Python dangermaus33 0 1,052 Apr-19-2022, 10:08 PM
Last Post: dangermaus33
  Inconsistent counting / timing with threading rantwhy 1 1,818 Nov-24-2021, 04:04 AM
Last Post: deanhystad
  Synchronization/Timing Problem quest 5 3,123 Mar-31-2021, 10:26 PM
Last Post: quest
  Timing of a while loop stylingpat 4 7,081 Mar-31-2021, 10:48 AM
Last Post: stylingpat
  Assigning Data from one column to another with different associated timing interval alexafshari 1 2,005 Apr-30-2020, 03:59 PM
Last Post: pyzyx3qwerty
  Frequency and timing of psycopg2 commits acecase 0 2,319 Nov-01-2019, 05:50 PM
Last Post: acecase
  Timing input Mark17 2 2,354 Oct-23-2019, 08:25 PM
Last Post: Mark17
  Timing functions with multiprocessing mntfr 3 5,137 Nov-18-2018, 06:00 AM
Last Post: woooee
  GPIO output timing help needed skid 5 4,170 Jan-23-2018, 04:12 PM
Last Post: skid
  change timing on py script kwfreverie 2 3,212 Dec-16-2017, 07:35 PM
Last Post: kwfreverie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020