Lesson 27 of 30

Lesson 27 ? Timer and countdowns

Title: Pause and count with time

Description: Use the time module for small countdowns and slow messages.

Why it matters for kids: Timers make games and animations feel alive.


1. Import time

pythonpython
import time

print("Ready")
time.sleep(1)
print("Go!")

sleep(1) waits for one second.


2. Countdown

pythonpython
import time

for number in range(5, 0, -1):
    print(number)
    time.sleep(1)

print("Blast off!")

3. Slow story

pythonpython
import time

print("The door creaks...")
time.sleep(1)
print("A tiny robot appears...")
time.sleep(1)
print("It gives you a cookie.")

4. Quick reaction message

pythonpython
import time

print("Wait for it...")
time.sleep(2)
print("Now press the imaginary button!")

5. Easy examples

pythonpython
import time

for word in ["Python", "is", "fun"]:
    print(word)
    time.sleep(0.5)
pythonpython
import time

seconds = 3
print(f"Waiting {seconds} seconds...")
time.sleep(seconds)
print("Done")
pythonpython
import time

print("Loading")
time.sleep(1)
print("Loaded")

6. Mini challenge

Click each example to open it.

Example 1

Print ready, wait, then print go.

Example 2

Wait one second with sleep.

Example 3

Count down from 3 to 1.

Example 4

Count down from 5 to 1.

Example 5

Print a slow three-line story.

Example 6

Wait half a second between words.

Example 7

Print loading, wait, then loaded.

Example 8

Make a tiny rocket countdown.

Example 9

Make a brushing teeth countdown.

Example 10

Change the wait time to two seconds.