Skip to content

useHireUp/Python-Alarm-Clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Console Alarm Clock

Welcome to the Console Alarm Clock assessment! This task asks you to build an interactive alarm clock program that runs in the terminal. It focuses on time handling, loops, and user interaction.


Objective

Create a program that lets users set, view, and delete alarms, and notifies the user in the console when an alarm time is reached.


Learning Goals

  • Work with Python's datetime and time modules
  • Manage multiple alarms using lists/dictionaries
  • Implement loops and sleeping (time.sleep) for polling the system clock
  • Validate user input (time formats)
  • Optionally implement persistence (save/load alarms) or audio notifications

Requirements (Detailed)

Your program must:

  1. Display a menu with at least these options:
1) Set alarm
2) List alarms
3) Delete alarm
4) Exit
  1. Set alarm:
  • Prompt user for a time in HH:MM format (either 24-hour or clear instructions for 12-hour with AM/PM).
  • Validate the input and add the alarm to an in-memory list.
  1. List alarms:
  • Show all scheduled alarms with index numbers.
  1. Delete alarm:
  • Allow user to remove an alarm by index number.
  1. Alarm triggering:
  • The program should check the current time periodically (e.g., every 15–30 seconds) and, when an alarm matches the current time, print a prominent notification such as:
[ALARM] It's 07:30! Wake up!
  • The notification should allow the user to choose to snooze (e.g., +5 minutes) or dismiss the alarm.
  1. Input validation:
  • Reject incorrect time formats or out-of-range values with helpful messages.
  1. (Optional bonuses):
  • Support multiple alarms and concurrent notifications.
  • Save/load alarms to/from a file (JSON) for persistence across runs.
  • Play a short sound using the system speaker or a small audio library (note: avoid external dependencies where possible).
  • Add repeat options (e.g., weekdays only).

Running the Program

  1. Save your file as:
alarm.py
  1. Run in terminal:
python alarm.py

or

python3 alarm.py

Notes:

  • While check_alarms is running it will block the menu; use Ctrl+C to return.
  • For more responsive behavior or GUI-like concurrency, consider threading (optional).

Example Interaction

Alarm Clock
1) Set alarm
2) List alarms
3) Delete alarm
4) Check/wait for alarms
5) Exit
Enter choice: 1
Enter alarm time (HH:MM, 24-hour): 07:30
Alarm set for 07:30.

Enter choice: 4
Waiting for alarms... (press Ctrl+C to return to menu)

[ALARM] It's 07:30! Wake up!
Snooze for 5 minutes? (yes/no): yes
Alarm snoozed to 07:35.

(press Ctrl+C to return to menu)
Enter choice: 2
1. 07:35
Enter choice: 5
Goodbye!

Bonus Ideas

  • Use JSON to save alarms and reload them on start

  • Implement snooze durations configurable by user

  • Allow recurring alarms (daily or weekdays only)

  • Use threading to check alarms in background while menu remains responsive

  • Play a simple beep or short audio file when alarm triggers (platform-dependent)


Submission

When finished:

git add alarm.py
git commit -m "Complete alarm clock assessment"
git push origin main

Resources

Tip: For testing, set alarms a minute or two ahead so you can verify behavior quickly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages