Python sleep()

import time

⏱️ Python — time.sleep() Practice Assignments

1) Simple Sleep Print

Write a program that prints “Hello”, then waits 2 seconds, then prints “World”.


2) Three-Second Pause

Print “Start”, pause for 3 seconds using time.sleep(3), then print “End”.


3) Countdown from 5

Using a loop and sleep(1), print:

5
4
3
2
1

4) Timer Print

Print current time (seconds since epoch), sleep 2 seconds, then print it again.


5) Sleep in Loop

Loop 5 times printing index 0–4 with a 1-second delay between each.


6) Prompt + Wait

Ask the user for their name. Print “Checking…”, sleep 1 second, then print “Welcome, !”.


7) Sleep with Message

Write:

so output shows a pause.


8) Wait for User Input

Ask user:

After pressing Enter, sleep 2 seconds and then print “Done!”.


9) Two-Phase Timer

Print “Phase 1”, sleep 1 second; then “Phase 2”, sleep 2 seconds; then “Finished”.


10) Speed Test (Slow / Fast)

Loop 3 iterations:

  • Sleep 1 second each

  • Print time each iteration


11) Sleep with Conditional

Ask user whether to sleep (“yes/ no”). If “yes”, sleep 3 seconds; else print “Skipping sleep”.


12) Delay Before Exit

Print “Program will end in 3 seconds…” Sleep 3 seconds, then exit.


13) Alternating Messages

Use loop:

repeat 3 rounds.


14) Sleep Progress Bar

Use loop and sleep to show:

pause 1 second between each.


15) Sleep Before Function

Define a function delayed_print(msg, delay) that sleeps for delay seconds then prints msg.


16) Sleep With Milliseconds

Use time.sleep() with a fractional delay (e.g., 0.3 seconds) inside a loop of 10 prints.


17) Date/Time Stamp Before & After Sleep

Print:


18) Sleep in Recursion

Write a recursive function that prints a number and sleeps 1 second, recursing until 0.


19) Countdown with Message

Countdown from 5 to 1; when reaching 1, sleep 2 seconds then print “Go!”.


20) Sleep & Multiplication Table

Ask user for a number. Print its multiplication table with 1-second pause between lines.


🧠 What You’re Practicing

  • how time.sleep() pauses execution

  • adding delays in loops

  • pausing between messages

  • timing and user experience flow


📌 Example Starter

or


canvil: 333f6c7d-6876-4f7e-b6ad-1bdb2233f5c1

Last updated