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. Table of Contents Python time sleep() Syntax sleep() Parameters sleep() Return Value
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.
Table of Contents
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.
1
time.sleep(seconds)
sleep()
ParametersThis 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 ValueIt does not return any value as it simply suspends the program execution for a particular period of time
Become a master of times and dates in Python as you work with the datetime and calender modules in this data science tutorial.
Python Programming Tutorials For Beginners
Guide to Python Programming Language
Python Hello World Program - Your first step towards Python world. Learn how to create the Hello World Python program in PyCharm.
In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.