Skip to main content
PRACTICE / AUTOMATING IT OPERATIONS / LESSON 05

Safe Remediation & Recovery.

Write eight independent Python helpers that validate the approval contract, block stale plans, build read-only previews, save rollback checkpoints, avoid duplicate changes, verify recovery and keep incidents open when results are uncertain.

8 coding challengesReal PythonAltered input fixturesFictional lab changes only

Real Python, simulated remediation: The browser workbench validates your functions against fictional change records only. No target is modified, no SSH or HTTP commands are executed, and no live ticket is updated. The written lesson contains an independent offline recovery project.

JOELEARNS / PYTHON WORKBENCH

Write it. Run it. Understand it.

Real Python execution, a variable trace and feedback against the requirements. You write the code—answers aren't revealed up front.

Python 3.14 · in-browser
CHALLENGE 01 / 8 · INTERMEDIATE → ADVANCED

Validate an exact, approved change request

Implement validate_change(req). Require a dictionary with exactly change_id, target, environment, action, expected_revision, desired_mode, approved. All six string fields must be nonempty strings without newline or carriage return; approved must be the actual boolean True. Only environment 'lab', action 'set-mode' and desired_mode 'enabled' or 'disabled' are permitted. Return a NEW dictionary with uppercase trimmed change_id/target, unchanged expected_revision (trimmed), normalized environment/action, normalized desired_mode and approved=True. Reject any missing/extra fields, wrong types, or invalid values. Print the sample normalized change ID.

EXPECTED OUTPUTCHG-201
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.

When you finish Practice, use the shared Continue Your Learning Path panel below to mark this milestone complete. Your next guided milestone is Lesson 06 — Integrated Operations Capstone, followed by the independent final coding assessment.

CONTINUE YOUR LEARNING PATH · AUTOMATING IT OPERATIONS

Ready for Phase 06?

You've reached the end of this Practice module. The next guided step is Integrated Operations Capstone. You can review your answers or revisit the lesson, but you don't need to return to the course roadmap to find what comes next. Next: milestone 11 of 12.

Your completion marks are saved in this browser only.