python program to create a countdown timer

Karthik Nagisetty Jul 14, 2023

In this project, we will like to see the countdown timer by using the Python program.

python program to create a countdown timer

In this project, we would like to see the countdown timer by using the Python program. The code will take input from the user regarding the length of the countdown in seconds. After that, a countdown will begin on the screen in the format  'minutes: seconds'. We will use the time module here.

 

countdown timer using python

import time
def countdown(t):
    while t:
        mins,secs=divmod(t,60)
        timer='{:2d}:{:02d}'.format(mins,secs)
        print(timer,end="\r")
        time.sleep(1)
        t -=1
    print('Fire in the hole!!')
t=input("Enter the time in seconds: ")
countdown(int(t))

 

 

 

Project Files

Loading...
..
This directory is empty.

Comments (0)

Leave a Comment