-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock&timer.py
49 lines (30 loc) · 1.05 KB
/
clock&timer.py
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
import time
from playsound import playsound
def userChoice(user_input):
if user_input == "1":
digitalClock()
elif user_input == "2":
second =int(input("Enter the number of second to countdown:"))
countdowntimer(second)
else:
print("Invalid Choice")
def digitalClock():
while True:
current_time = time.strftime("%H:%M:%S",time.localtime())
print("\r Digital Clock: "+current_time,end='')
time.sleep(1)
def countdowntimer(second):
print("Countdown Timer startrd!")
for i in range(second, -1, -1):
print("\rTime remaining : "+ str(i),end ='')
time.sleep(1)
playsound("Top-Touches-Wow.mp3")
print("\n Time's up!")
print("\n")
while True:
user_input = input("""
Choose an option(1 or 2):
1.Digital Clock
2.Countdown Timer
\n""")
userChoice(user_input)