+2 votes
2 views
in Python by (3.5k points)
edited by
Can someone tell me how to put time delay in the script of Python?

2 Answers

0 votes
by (46.1k points)
edited by

To make a time delay use this syntax:

import time
time.sleep(3)   # Delays for 3 seconds. Float value can also be used.

I am attaching one more example where you can run something in approximately three minutes:

import time
while True:
    print("This prints once a minute.")
    time.sleep(180) # Delay for 3 minute (180 seconds).

Hope this helps. Cheers..!! 

0 votes
by (107k points)

You can use the sleep() function in the time module. It can take a float argument for sub-second resolution.

from time import sleep

sleep(0.1) 

You can use the following video tutorials to clear all your doubts:-

Related questions

0 votes
1 answer
+1 vote
1 answer
+2 votes
2 answers
asked May 23, 2019 in Python by Anvi (10.2k points)
+1 vote
2 answers
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...