Home Interests Code

Python time.sleep() – How to Make a Time Delay in Python

howchoo   (467)
September 13, 2023
3 minutes


You'll Need 1

What you'll need
python x 1
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
code • 11 guides
python • 18 guides

Learn how to use Python’s sleep function to make a timed delay.


import time

1 – Import the time module

We will first want to import Python’s time module:

import time

This module ships with Python so it should be available on any system. Although it is not necessary for this guide, I highly recommend getting familiar with the time module. Read more about the time module here.

2 – Use time.sleep to set the delay

You can set a delay in your Python script by passing the number of seconds you want to delay to the sleep function:


This means you want the script to delay 5 seconds before continuing. The sleep function also accepts floats if you want to give a more precise number:


This will sleep for 1 second and 750 milliseconds. You can also use a float to delay for less than a second like this:


This will sleep for half of a second. You can and should read more about Python’s sleep function here.


Secure Your Sensitive Data with Kubernetes Secrets

Learn how to create and use Kubernetes secrets.
howchoo   (467)
November 26, 2023

Kubernetes secrets are objects that store and manage sensitive data inside your Kubernetes cluster. One mistake developers often make is storing sensitive information like database passwords, API credentials, etc in a settings file in their codebase. This is very bad practice (hopefully for obvious reasons). Most developers know this, but still choose the option because it’s easy.

Continue Reading


 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.