Cheap Jerseys Cheap NFL Jerseys Cheap NFL Jerseys Cheap Football jerseys Cheap NFL Jerseys Wholesale Jerseys Cheap NHL Jerseys Cheap Jerseys From China Cheap MLB Jerseys Cheap Jerseys Cheap Jerseys Cheap Jerseys Wholesale Jerseys Python time sleep() Method (Tutorial) - WTMatter

Python time sleep() Method (Tutorial)

Python Time Sleep() Method

This is a detailed tutorial of the Python sleep() Method. Learn to suspend the execution of a given Python program or code for a given number of seconds.

Python time sleep()

The method sleep() of the Python time module is used to suspend the execution of a given Python program for the desired number of seconds. It’s a kind of function to pause your Python code execution for some time.


Given below is the syntax for the sleep() method.

sleep() Parameters

This method only takes a single argument and that is the time in seconds. This is a floating-point number value. You can simply provide the seconds argument as an integer value to just specify the timings upto the precision of seconds. But if you want the execution suspension timings to be more precise, you can use floating-point numbers.

For example, the valid values of this argument are 1, 2, 3.5, 4.965, etc.

sleep() Return Value

It does not return any value as it simply suspends the program execution for a particular period of time.


Given below is an example illustrating the purpose of the Python time sleep() method. Here we’ve first imported the time module and then printed the current time using the ctime() method. Then we’ve suspended the program execution for 4 seconds using this method and then again printed the current time.

import time


#Suspending Execution for 4 seconds



As you can notice the two printed timings, there’s a difference of 4 seconds because for that interval of time, the program execution was suspended and the control was sleeping.

Thu Jul  9 07:51:10 2020
Thu Jul  9 07:51:14 2020

Similarly, another python code given below suspends the execution of the program, even more precisely. Here we’ve just requested to pause the execution for 3.569 seconds i.e. for 3 seconds and 569 milliseconds.

import time


#Suspending Execution for 3 seconds and 569 milliseconds




I hope you found this guide useful. If so, do share it with others who are willing to learn Python. If you have any questions related to this article, feel free to ask us in the comments section.

And do not forget to subscribe to WTMatter!

Subscribe To WTMatter!

Receive updates of our latest articles via email. Enter your email address below to get started.

Leave a Reply

Your email address will not be published. Required fields are marked *