Python: Suspend execution of a given script a given number of seconds
Python Datetime: Exercise-58 with Solution
Write a Python program that can suspend execution of a given script for a given number of seconds.
Sample Solution:
Python Code:
import time
for x in range(4):
time.sleep(3)
print("Sorry, Slept for 3 seconds...")
Sample Output:
Sorry, Slept for 3 seconds... Sorry, Slept for 3 seconds... Sorry, Slept for 3 seconds... Sorry, Slept for 3 seconds...
Flowchart:

Python Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Python program to get different time values with components timezone, timezone abbreviations, the offset of the local (non-DST) timezone, DST timezone and time of different timezones.
Next: Write a Python program to convert a given time in seconds since the epoch to a string representing local time.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join