-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer2.py
More file actions
27 lines (27 loc) · 901 Bytes
/
timer2.py
File metadata and controls
27 lines (27 loc) · 901 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
import time
import pygame
pygame.mixer.init()
alarm = pygame.mixer.Sound("alarm_ding.ogg")
alarm_len = alarm.get_length()
#____________________________________________________________
print("It will play a sound at the end...\n")
print("Now, we can type the enter key for value 0\n")
#____________________________________________________________
try:
minutes = int(input ("Minutes:"))*60
except ValueError:
minutes = 0*60
try:
seconds = int(input("Seconds:"))
except ValueError:
seconds = 0
timer = minutes + seconds
for i in range(timer):
print("", str(timer - i), end="\r")
time.sleep(1)
alarm.play()
print("time's over\n")
#____________________________________________________________________
print("Check and Download this code at https://github.com/edif/Countdown-timer\n")
#____________________________________________________________________
time.sleep(alarm_len)