Click here to Skip to main content
15,311,717 members
Please Sign up or sign in to vote.
1.12/5 (4 votes)
See more: , +
I'm trying to implement the monitor function in Python.

This function must display at regular interval the date followed by the return of the "measure" function. It stops after `cycles` executions and the interval will never be less than 1.
The function's execution time must be less than (cycles + 1) * interval


What I have tried:

def monitor(interval=1.0, cycles=42):
  def measure():
    time.sleep(random.random())
    return random.randint(123, 456)
  pass
Posted
Updated 31-Aug-21 17:39pm

1 solution

Read the question again: you have to display a message at regular intervals.

So ... the first thing you will need is a loop of some form ...

Read it carefully - it tells you exactly what to do, and the code you show doesn't fit it at all!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900