Python 3 Script to Build a Digital Clock Countdown Timer Using Time Module

Python 3 Script to Build a Digital Clock Countdown Timer Using Time Module

Python 3 Script to Build a Digital Clock Countdown Timer Using Time Module

# import the time module
import time

# define the countdown func.
def countdown(t):
    
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:02d}:{:02d}'.format(mins, secs)
        print(timer, end="r")
        time.sleep(1)
        t -= 1
    
    print('Fire in the hole!!')


# input time in seconds
t = input("Enter the time in seconds: ")

# function call
countdown(int(t))
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment