Advertisement
here2share

# basic_alarmclock.py

Feb 15th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. # basic_alarmclock.py
  2.  
  3. import winsound ###
  4.  
  5. from time import strftime, sleep
  6. timein = raw_input("What time shall I ring? (HH:MM) 12hr format > ")[:-1] # removes the '\r' at the end
  7. ampm = raw_input("AM or PM? ")
  8.  
  9. if ampm.upper()[0] is 'P': ampm = ' PM'
  10. else: ampm = ' AM'
  11.  
  12. timein = timein + ampm
  13.  
  14. while True:
  15.     secs = strftime("%S")
  16.     t = strftime("%I:%M %p")
  17.     print
  18.     print timein
  19.     print strftime("%I:%M:%S %p"),
  20.     if timein in (t,t[1:]):
  21.         print "-- The Time Has Come!"
  22.         ### play alarm sound
  23.         winsound.Beep(3000,75) ###
  24.         winsound.Beep(2000,75) ###
  25.         if secs > '09': break
  26.     else: print
  27.     while secs == strftime("%S"):
  28.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement