Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # basic_alarmclock.py
- import winsound ###
- from time import strftime, sleep
- timein = raw_input("What time shall I ring? (HH:MM) 12hr format > ")[:-1] # removes the '\r' at the end
- ampm = raw_input("AM or PM? ")
- if ampm.upper()[0] is 'P': ampm = ' PM'
- else: ampm = ' AM'
- timein = timein + ampm
- while True:
- secs = strftime("%S")
- t = strftime("%I:%M %p")
- print
- print timein
- print strftime("%I:%M:%S %p"),
- if timein in (t,t[1:]):
- print "-- The Time Has Come!"
- ### play alarm sound
- winsound.Beep(3000,75) ###
- winsound.Beep(2000,75) ###
- if secs > '09': break
- else: print
- while secs == strftime("%S"):
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement