Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Countdown Timer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Countdown Timer

This program takes in the number of seconds to countdown and displays a message when the time elapses.

# Prerequisites

It requires no prerequisites, you only need to run the script. If you don't have Python installed, you can visit [here](https://www.python.org/downloads/) to download Python.

# How to run the script

Running the script is pretty easy, open a terminal in the folder where your script is located and run the following command :

`python timer.py`

# Author's name

[KOTHA V V S AAKASH](https://github.com/AakashKotha)
48 changes: 48 additions & 0 deletions Countdown Timer/timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import time

def countdownTimer():
# get the number of seconds
no_of_secs = int(input('How many seconds?: '))
while no_of_secs:
if no_of_secs < 60:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = no_of_secs // 60
secs = no_of_secs % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
elif 60 <= no_of_secs < 3600:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = no_of_secs // 60
secs = no_of_secs % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
elif 3600 <= no_of_secs <= 86400:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = (no_of_secs % 3600) // 60
secs = (no_of_secs % 3600) % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
print('Time Up!')

countdownTimer()
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Incase there is something that needs to be followed while executing the python s
| Wikipedia Data Extractor | [Wikipedia Data Extractor](https://github.com/DhanushNehru/Python-Scripts/tree/master/Wikipedia%20Data%20Extractor) | Simple Wikipedia data extractor script to get output in your IDE |
| Youtube Downloader | [Youtube Downloader](https://github.com/DhanushNehru/Python-Scripts/tree/master/Youtube%20Downloader) | Download any video from [YouTube](https://youtube.com) in video or audio format! |
| Weight Coverter | [Weight Converter](https://github.com/WatashiwaSid/Python-Scripts/tree/master/Weight%20Converter) | Simple GUI script to convert weight in different measurement units |

| Countdown Timer | [Countdown Timer](https://github.com/DhanushNehru/Python-Scripts/tree/master/Countdown%20Timer) | Displays a message when the Input time elapses |

### Project Contributors
<a href="https://github.com/DhanushNehru/Python-Scripts/graphs/contributors">
<img src="https://contrib.rocks/image?repo=DhanushNehru/Python-Scripts" />
</a>
</a>