Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
7 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 (46k 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 (106k 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:-

Learn in detail about Python by enrolling in Intellipaat Python Course online and upskill.

Related questions

0 votes
1 answer
asked Feb 7, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer
+1 vote
1 answer
+1 vote
2 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...