Skip to content

Commit f1cfaec

Browse files
author
Karan Goel
committed
Alarm clock done
Right now it beeps, need to add ability to play a sound.
1 parent 4e25c96 commit f1cfaec

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Numbers/alarm.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Alarm Clock - A simple clock where it plays a sound after
3+
X number of minutes/seconds or at a particular time.
4+
"""
5+
6+
import time
7+
import winsound
8+
9+
if __name__ == '__main__':
10+
hh = input('What hour do you want to wake up (0-23)? ')
11+
mm = input('What minute do you want to wake up (0-59)? ')
12+
13+
not_alarmed = 1
14+
15+
while(not_alarmed):
16+
cur_time = list(time.localtime()) # get the time right now
17+
hour = cur_time[3] # find the hour
18+
minute = cur_time[4] # and the minute
19+
if hour == hh and minute == mm:
20+
winsound.Beep(10000, 100) # play the beep
21+
not_alarmed = 0 # stop the loop
22+

0 commit comments

Comments
 (0)