Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Code an alarm clock using Python! โฐ
Play lesson

Python tutorial for beginners ๐Ÿ - Code an alarm clock using Python! โฐ

4.0 (0)
8 learners

What you'll learn

This course includes

  • 14.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#python #pythontutorial #pythoncourse # Python Alarm Clock import time import datetime import pygame def set_alarm(alarm_time): print(f"Alarm set for {alarm_time}") sound_file = "my_music.mp3" is_running = True while is_running: current_time = datetime.datetime.now().strftime("%H:%M:%S") print(current_time) if current_time == alarm_time: print("WAKE UP! ๐Ÿ˜ด") pygame.mixer.init() pygame.mixer.music.load(sound_file) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): time.sleep(1) is_running = False time.sleep(1) if __name__ == "__main__": alarm_time = input("Enter the alarm time (HH:MM:SS): ") set_alarm(alarm_time)

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere