Skip to content

Commit 7b3366c

Browse files
author
balgowlah-deli
committed
Create countdown_timer.py
1 parent 5df3be2 commit 7b3366c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

countdown_timer.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# import the time module
2+
import time
3+
4+
# define the countdown func.
5+
def countdown(t):
6+
7+
while t:
8+
mins, secs = divmod(t, 60)
9+
timer = '{:02d}:{:02d}'.format(mins, secs)
10+
print(timer, end="\r")
11+
time.sleep(1)
12+
t -= 1
13+
14+
print('Fire in the hole!!')
15+
16+
17+
# input time in seconds
18+
t = input("Enter the time in seconds: ")
19+
20+
# function call
21+
countdown(int(t))
22+

0 commit comments

Comments
 (0)