Python program to create a countdown timer

Today we are here to show the tutorial of how to create a countdown timer in Python. We have added the video tutorial, the source code and the output of it. So let us start with a Python program to create a countdown timer.

 

Video Tutorial: Python program to create a countdown timer

 

Source Code: Python program to create a countdown timer

 

#Python Countdown timer
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("Timer Ended!")
countdown (5)

 

Output:-

Python program to create a countdown timer

 

Also read: Python Square Spiral Pattern turtle

Leave a Reply

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