Premium Only Content

Countdown Timer Using Function In Python-Free Python Course
In this project, we will be using the time module and its sleep() function. Follow the below steps to create a countdown timer:
Step 1: Import the time module.
Step 2: Then ask the user to input the length of the countdown in seconds.
Step 3: This value is sent as a parameter 't' to the user-defined function countdown(). Any variable read using the input function is a string. So, convert this parameter to 'int' as it is of string type.
Step 4: In this function, a while loop runs until time becomes 0.
Step 5: Use divmod() to calculate the number of minutes and seconds. You can read more about it here.
Step 6: Now print the minutes and seconds on the screen using the variable timeformat.
Step 7: Using end = '\r' we force the cursor to go back to the start of the screen (carriage return) so that the next line printed will overwrite the previous one.
Step 8: The time.sleep() is used to make the code wait for one sec.
Step 9: Now decrement time so that the while loop can converge.
Step 10: After the completion of the loop, we will print "Fire in the hole" to signify the end of the countdown.
-
LIVE
Lofi Girl
2 years agoSynthwave Radio 🌌 - beats to chill/game to
198 watching -
3:07:24
FreshandFit
9 hours agoPrivileged Nigerian Thinks Women Created Everything: HEATED DEBATE
141K79 -
5:57:27
SpartakusLIVE
10 hours agoNEW Update - BROKEN Attachment || Viewers REJOICE at the long-awaited Return of Their KING
74.9K -
2:06:31
TimcastIRL
9 hours agoTrump To Deploy National Guard To Portland, Antifa Has Been WIPED OUT | Timcast IRL
189K156 -
2:30:00
Laura Loomer
11 hours agoEP142: Loomer Prompts Calls For FBI To Investigate Palestinian Youth Movement
49.8K19 -
1:26:34
Man in America
13 hours agoExposing the Cover-Up That Could Collapse Big Medicine: Parasites
56.3K23 -
4:53:00
CHiLi XDD
9 hours agoTekken Fight Night
30K1 -
9:25:57
ItsLancOfficial
14 hours agoFREAKY FRIDAY-GETTING FRIED-WELP! #TOTS
30.1K3 -
1:09:11
Sarah Westall
10 hours agoRead the Signs: Are We Already Operating in a New Financial System? w/ Andy Schectman
42K8 -
1:32:53
Flyover Conservatives
13 hours agoRicky Schroder Exposes How Hollywood Planted Him as a Child Star | FOC Show
54.8K14