How do I implement this function in Python?

13 views
Skip to first unread message

Mehrez Kanzari

unread,
Aug 27, 2021, 3:03:45 AM8/27/21
to Python Tunisia
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

def monitor(interval=1.0, cycles=42):

def measure():

time.sleep(random.random())

return random.randint(123, 456)

pass

Reply all
Reply to author
Forward
0 new messages