Daily Python Projects
Python Code Dictations
Simple Alarm Clock - Python Code Dictation
0:00
-3:06

Simple Alarm Clock - Python Code Dictation

Level: Easy 🟡

What is this post about?

This is an audio code dictation to help learners memorize Python syntax. Follow these steps to complete a dictation:

  1. Open a code editor on your computer.

  2. Play the audio and type the narrated code while listening.

  3. Compare your code with the correct code below.

Correct Code

import time

def set_alarm(hours, minutes):
    print("Alarm set for", hours, minutes)
    current_time = time.localtime()
    while current_time.tm_hour != hours or current_time.tm_min != minutes:
        current_time = time.localtime()
        time.sleep(30)
    print("Time's up! Wake up!")

set_alarm(6, 30)

Explore More Dictations

Discussion about this episode

User's avatar