Timer Program

Computer Science | Artificial Intelligence | Computational Biology | Chess | Blender

Timer Program

This is a simple Python program that acts as a timer. The program takes a user input of the time in seconds and counts down to zero. The program is useful for timing tasks and activities that require a specific duration.

Below is the program.


Timer Program

import time

tik_tok = int(input("Enter seconds: ")) # Enter seconds

for i in range(tik_tok,0,-1): # Iterate for every second
    seconds = int(i) % 60 # The seconds shouldn't exceed 60 seconds
    minutes = int(i / 60) % 60 # Minutes don't go above 60 minutes
    hours = int(i / 3600) % 24 # Hours shouldn't exceed 24 hours
    days = int(i / 86400) % 7 # Days shouldn't exceed 7 days
    weeks = int(i / 604800)
    time.sleep(1) # Time will delay by 1 second
    print(f"W{weeks:02} D:{days:02} H:{hours:02} M:{minutes:02} S:{seconds:02}")