Tags
python
Asked 3 years ago
16 Aug 2021
Views 427
Hope

Hope posted

How do you delay 1 second in Python ?

How do you delay 1 second in Python?
sachin

sachin
answered Aug 16 '21 00:00


import time
time.sleep(1)


sleep function is used for the sleep code execution in seconds
sleep(s) where s is a parameter which is in seconds.
sleep is from the time package so you need to add import time and to invoke like below :
time.sleep(1) // for 1 second delay
time.sleep(10) // for 10 second delay

what if you want to delay 1 minute in Python then

import time
time.sleep(60)


time.sleep(60) // it will delay 60 seconds which is a one-minute delay total in Python

what if you want to delay 1 hour in Python then

import time
time.sleep(60*60)


time.sleep(3600) // it will delay 3600 second which is one hour delay total in Python

Post Answer