countdown animation python code example
Example 1: 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))
Example 2: how to make a timer in python
#Timer in python
#pip install playsound
import time
import playsound
question = int(input('How many seconds to wait: '))
time.sleep(question)
playsound.playsound('Hello.mp3')