Monday, March 12, 2018

Time sleep() Method


Time sleep() Method in Python 3


The method sleep() suspends execution for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time.

The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal's catching routine.

Syntax
time.sleep(t)


Parameters
t - This is the number of seconds for which the execution is to be suspended.
Return Value
This method does not return any value.

Example
#!/usr/bin/python3
import time
print ("Start : %s" % time.ctime())
time.sleep( 5 )
print ("End : %s" % time.ctime())

When we run the above program, it produces the following result-

Start : Sun Mar 11 23:28:24 2018
End : Sun Mar 11 23:28:29 2018