Skip to content

Commit 111e700

Browse files
authored
Merge pull request #147 from Iamabitch/patch-3
Create CountdownTimer.py
2 parents 51b8d95 + d826158 commit 111e700

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Basic Scripts/CountdownTimer.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
3+
# The countdown function is defined below
4+
5+
def countdown(t):
6+
7+
while t:
8+
9+
mins, secs = divmod(t, 60)
10+
11+
timer = '{:02d}:{:02d}'.format(mins, secs)
12+
13+
print(timer, end="\r")
14+
15+
time.sleep(1)
16+
17+
t -= 1
18+
19+
print('Lift off!')
20+
21+
# Ask the user to enter the countdown period in seconds
22+
23+
t = input("Enter the time in seconds: ")
24+
25+
# function call
26+
27+
countdown(int(t))

0 commit comments

Comments
 (0)