-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer_hms.py
More file actions
executable file
·55 lines (40 loc) · 1.4 KB
/
timer_hms.py
File metadata and controls
executable file
·55 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python3.5
import os
import time
import random
def SpaceSeparator():
print("\n")
os.system('clear')
SpaceSeparator()
print(" Welcome to PyCountdownTimer!\n\n Let's set up that countdown timer...\n\n")
hours = input(" How many hours? ")
SpaceSeparator()
minutes = input(" How many minutes? ")
SpaceSeparator()
seconds = input(" How many seconds? ")
if hours or minutes or seconds == "":
print("Invalid entry. You must enter a number.")
hours = int(hours)
minutes = int(minutes)
seconds = int(seconds)
hrsToSec = (hours * 60) * 60
mnsToSec = (minutes * 60)
seconds = seconds
seconds = hrsToSec + mnsToSec + seconds
print(seconds)
os.system('clear')
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)
os.system('clear')
print("\n Your time remaining is: {}:{}:{}".format(str(displayHours).zfill(2), str(displayMinutes).zfill(2), str(displaySeconds).zfill(2)))
seconds -= 1
time.sleep(1)
os.system('clear')
randQuot = ('I bid you peace.', 'May the Force be with you.', 'Live long and prosper.', 'May God bless.', 'Happy trails to you, \'til we meet again.')
print('\n Timer ended. {}\n'.format(random.choice(randQuot)))