Python 3 Script to Build a Digital Clock Countdown Timer Using Time Module Full Example Project For Beginners

 

 

Welcome folks today in this blog post we will be building a digital clock countdown timer using time module in python. All the full source code of the application is shown below.

 

 

 

 

Get Started

 

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

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

 

See also  Python 3 Script to Perform Remote Commands Over SSH Client Protocol on Command Line Automatically Full Project For Beginners

 

Now if you execute the python script by typing the below command as shown below

 

 

python app.py

 

 

 

Leave a Reply