Coders Packet

python program to create a countdown timer

By Karthik Nagisetty

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))

 

 

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Karthik Nagisetty (karthik)

Download packets of source code on Coders Packet