Free Friday: 12/19/25

Today, I watched a video and created a Python alarm clock. This video helped me better understand Python’s time and datetime modules. The program runs in the terminal, asks the user to enter a time, and then waits until that time to play a sound and alert the user.

SNIPPETS:

import time
import datetime
import pygame

^These imports provide the tools needed for the program. time and datetime let the program keep track of the current time, and pygame is used to play a music file when the alarm goes off.

def set_alarm(alarm_time):
    print(f"Alarm set for {alarm_time}")
    sound_file = "my_music.mp3"
    is_running = True

^This function sets up the alarm. It prints the time the alarm is set for, chooses a sound file to play, and creates a loop to keep the alarm running.

Leave a Reply

Your email address will not be published. Required fields are marked *