Skip to main content
PRACTICE / APPLIED PYTHON / LESSON 05

Logging, Testing & Reliability Coding Clinic.

Eight real Python challenges where you implement logging behavior, protect secrets, write unittest cases, inject failure scenarios, and keep reports safe when retries or API validation fail.

8 coding challengesReal Pythonunittest and mocksMultiple failure fixtures

Test the failures, not only the happy path. The workbench executes Python in its isolated browser environment with fictional data. The mock clients do not contact a service; no access tokens or customer records are involved. Run experiments with your own code; Check uses the example plus additional test cases, including unsuccessful outcomes and preservation of previous reports.

The local unittest assignment shows how to run the same habits from your own Python project, including verifying a failing test can fail.

JOELEARNS / PYTHON WORKBENCH

Write it. Run it. Understand it.

Implement safe logging, unittest assertions, injected mock failures, bounded retries and deterministic report recovery in real Python.

Python 3.14 · in-browser
CHALLENGE 01 / 8 · BEGINNER

Choose meaningful logging severity

Write event_level(kind) using Python's logging module, returning the integer logging level for start/complete (INFO), retry (WARNING), and failed (ERROR). Return None for unknown event names. Do not configure handlers or print inside the helper. Print the three level names for the sample. The grader changes event order and checks that a failed operation is not logged as INFO.

EXPECTED OUTPUTINFO,WARNING,ERROR
script.py editableCtrl / Cmd + Enter to run
Your code is stored only in session storage when enabled. Never paste secrets. Clearing this option clears saved drafts, not the editor.
Code executes only when you choose Run or Check. No account needed.
HINTS · OPTIONAL

Try solving it before asking for help. Hints never show a completed program.

PYTHON OUTPUTReady

Your printed output and errors will appear here.

VARIABLE TRACER

Run the code, then step through the executed lines to watch variable values change.

About this environment: The Python runtime is loaded on demand from a version-pinned CDN and runs inside a sandboxed, opaque-origin browser frame. Runs have a time limit. OS/network automation is outside this introductory workbench. If your code calls input(), a response panel appears to supply text to those calls. Don't paste secrets or untrusted scripts.