How to put time delay in Python?

0 votes
I want to know how to halt the flow of a program for some time, in Python?
May 28 in Python by Shabnam
• 400 points
10 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can use sleep() method to sleep a thread for a specified amount of time. This method provides accurate and flexible way to halt a code for any period of time.

Have a look at the below given example for better understanding:

Input:

import time 

#printing the time when code execution began


print("code execution began at : ", end ="")
print(time.ctime()) 

#using sleep to halt the code execution

time.sleep(10) 

#printing the time when code execution ended

print("code execution ended at : ", end ="") 
print(time.ctime()) 

Output:

code execution began at : Tue May 28 07:41:48 2019

code execution ended at : Tue May 28 07:41:58 2019

answered May 28 by Taj
• 560 points

Related Questions In Python

0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8 in Python by rajesh
• 1,210 points
38 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,710 points
23 views
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,500 points
115 views
0 votes
1 answer

How to calculate time interval between two time strings in Python

Try doing this - It is efficient for ...READ MORE

answered Nov 29, 2018 in Python by Nymeria
• 3,500 points

edited Dec 11, 2018 by Nymeria 78 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
55 views
+4 votes
6 answers
+1 vote
1 answer

How can I reverse list in Python?

Reversing a list is a commonly used ...READ MORE

answered May 13 in Python by Taj
• 560 points
19 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.