Answers for "countdown clock and timer in python"

4

countdown timer with python

import time
import pyttsx3

def countdown(t):
    while t:
        mins, seconds = divmod(t, 60)
        timer = "{:02d}:{:02d}".format(mins,seconds)
        print(timer, end="r")
        time.sleep(1)
        t -= 1
        
    pyttsx3.speak("Beep Beep Beep Beep Beep Beep")
    pyttsx3.speak("Timer has completed")
    print("Timer has done")
timer = int(input("Enter the time in seconds:- "))

print(countdown(timer))
Posted by: Guest on June-25-2021
0

py countdown

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


# put time in seconds here
t = 10

# function call 
countdown(int(t))
Posted by: Guest on November-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language