import time while True: print("This prints once a minute.") time.sleep(60) # Delay for 1 minute (60 seconds).
Here is what the above code is Doing:
1. It’s creating an infinite loop.
2. It’s printing a message.
3. It’s sleeping for 60 seconds.
4. It’s going back to step 1.
You can also use the time module to measure how long something takes.
Here’s an example:
import time
start_time = time.time()
# Code you want to measure goes here
elapsed_time = time.time() – start_time