Python Program to Create a Countdown Timer – 2024

Hey guys, in this blog we will see a Python Program to Create a Countdown Timer.

Countdown time in Python

import time

def countdown(time_sec):
    while time_sec:
        mins, secs = divmod(time_sec, 60)
        timeformat = '{:02d}:{:02d}'.format(mins, secs)
        print(timeformat, end='\r')
        time.sleep(1)
        time_sec -= 1

    print("stop")

countdown(5)
  • This will create a counter in python which will count backward from 5 to 0.

00:05
00:04
00:03
00:02
00:01

Check out our other python programming examples

Subscribe to our Newsletter

Subscribe to our newsletter and receive all latest projects...

Leave a Reply

Your email address will not be published. Required fields are marked *