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
38 changes: 38 additions & 0 deletions Countdown_clock_and_Timer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Countdown Clock and Timer
## Description
A simple timer that can be used to track runtime. The purpose of this is to provide a simple, and standard, way of tracking runtime.
- This is very useful when testing implementations, and helpful when tracking the progress of longer-running programs.
- The app will notify the user that the time has ended.

### Language
- [X] Python

### Checklist
Name | About
:------------------ | :------------------
Countdown clock and timer | Shows the current time and timer according to the user input.

### Usage
To access the `timer`, this application imports the following modules.
```python
import os
import time
```

### Instructions to run this application

1. Download and Run the __countdown_clock_and_timer.py__
2. Set the countdown time.
3. Enter the hours, minutes and seconds .
4. Timer will be set according to the given input by the user.
5. It will show the countdown time and display it when the time gets over.

##### Example Output
Output will be shown like that for the three seconds -
```
00:00:03
00:00:02
00:00:01
00:00:00
'Time is over'
```
46 changes: 46 additions & 0 deletions Countdown_clock_and_Timer/countdown_clock_and_timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# import modules like 'os' and 'time'
import os
import time

os.system('clear')

# using ctime() to show present time
times = time.ctime()
print("\nCurrent Time: ",times)

print("\n Welcome to CountdownTimer!\n\n Let's set up the countdown timer...\n")

# User input for the timer
hours = int(input(" How many hours? "))
minutes = int(input(" How many minutes? "))
seconds = int(input(" How many seconds? "))

# To display message when the given value is not a number
if hours or minutes or seconds == "":
print("\n Invalid entry. You must enter a number.")

# Conversion of hours amd minutes into seconds
hrsToSec = (hours * 60) * 60
mnsToSec = (minutes * 60)
seconds = seconds

seconds = hrsToSec + mnsToSec + seconds
print("\n Timer has been set for "+str(seconds) + " seconds.")

# Loop for displaying the timer

for i in range(seconds, -1, -1):
displayHours = int(seconds / 3600)
displayMinutes = int(seconds / 60)
if displayMinutes >= 60:
displayMinutes = displayMinutes - (displayHours * 60)
else:
displayMinutes = displayMinutes
displaySeconds = int(seconds % 60)
print("\n Your time remaining is: {}:{}:{}".format(str(displayHours).zfill(2), str(displayMinutes).zfill(2), str(displaySeconds).zfill(2)))
seconds -= 1
time.sleep(1) # delays in the excution of a program for 1 second

print("\n Time is over.")