forked from kal179/Beginners_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.py
More file actions
28 lines (23 loc) · 908 Bytes
/
timer.py
File metadata and controls
28 lines (23 loc) · 908 Bytes
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import time
import webbrowser
def timer(s, hrs, mins, secs):
# Convert time into seconds
_n = secs + mins*60 + hrs*60*60
print("\nTimer Started...")
print("> Countdown for: %i hours:%i minutes:%i seconds" %(hrs, mins, secs))
# This is where real timer works
# -0.01 is assumed time for execution of above instructions
time.sleep(_n - 0.01)
print("Time's up!")
print("...\...Playing Sound.../...")
# Play sound after timer count completion
webbrowser.open(s)
while True:
if raw_input("\nContinue[Y/n]? ").strip().lower() == "y":
timer(raw_input("\nSound(Link)?: ").strip(), int(raw_input("Hours?: ").strip()), int(raw_input("Minutes?: ").strip()), int(raw_input("Seconds?: ").strip()))
else:
print("\nHope You Enjoyed!")
sys.exit(0)