Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f164acc

Browse files
Merge pull request avinashkranjan#400 from Ayush7614/master
Countdown_clock_and_Timer
2 parents a134b67 + 6779d27 commit f164acc

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

‎Countdown_clock_and_Timer/README.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Countdown Clock and Timer
2+
## Description
3+
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.
4+
- This is very useful when testing implementations, and helpful when tracking the progress of longer-running programs.
5+
- The app will notify the user that the time has ended.
6+
7+
### Language
8+
- [X] Python
9+
10+
### Checklist
11+
Name | About
12+
:------------------ | :------------------
13+
Countdown clock and timer | Shows the current time and timer according to the user input.
14+
15+
### Usage
16+
To access the `timer`, this application imports the following modules.
17+
```python
18+
import os
19+
import time
20+
```
21+
22+
### Instructions to run this application
23+
24+
1. Download and Run the __countdown_clock_and_timer.py__
25+
2. Set the countdown time.
26+
3. Enter the hours, minutes and seconds .
27+
4. Timer will be set according to the given input by the user.
28+
5. It will show the countdown time and display it when the time gets over.
29+
30+
##### Example Output
31+
Output will be shown like that for the three seconds -
32+
```
33+
00:00:03
34+
00:00:02
35+
00:00:01
36+
00:00:00
37+
'Time is over'
38+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# import modules like 'os' and 'time'
2+
import os
3+
import time
4+
5+
os.system('clear')
6+
7+
# using ctime() to show present time
8+
times = time.ctime()
9+
print("\nCurrent Time: ",times)
10+
11+
print("\n Welcome to CountdownTimer!\n\n Let's set up the countdown timer...\n")
12+
13+
# User input for the timer
14+
hours = int(input(" How many hours? "))
15+
minutes = int(input(" How many minutes? "))
16+
seconds = int(input(" How many seconds? "))
17+
18+
# To display message when the given value is not a number
19+
if hours or minutes or seconds == "":
20+
print("\n Invalid entry. You must enter a number.")
21+
22+
# Conversion of hours amd minutes into seconds
23+
hrsToSec = (hours * 60) * 60
24+
mnsToSec = (minutes * 60)
25+
seconds = seconds
26+
27+
seconds = hrsToSec + mnsToSec + seconds
28+
print("\n Timer has been set for "+str(seconds) + " seconds.")
29+
30+
# Loop for displaying the timer
31+
32+
for i in range(seconds, -1, -1):
33+
displayHours = int(seconds / 3600)
34+
displayMinutes = int(seconds / 60)
35+
if displayMinutes >= 60:
36+
displayMinutes = displayMinutes - (displayHours * 60)
37+
else:
38+
displayMinutes = displayMinutes
39+
displaySeconds = int(seconds % 60)
40+
print("\n Your time remaining is: {}:{}:{}".format(str(displayHours).zfill(2), str(displayMinutes).zfill(2), str(displaySeconds).zfill(2)))
41+
seconds -= 1
42+
time.sleep(1) # delays in the excution of a program for 1 second
43+
44+
print("\n Time is over.")
45+
46+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /