Skip to main content
PRACTICE / APPLIED PYTHON / LESSON 02

Command-Line Tools Coding Clinic.

Eight coding challenges on argument parsing, defaults, choices, numeric validation, Boolean flags, configuration precedence, status codes and an independent read-only inventory reporter. Build the behavior, not just a sample output.

8 coding challengesReal Python argparseIndependent inputsOffline fictional data

Testable parser design: Every task passes argument tokens directly as a Python list to parse_args(argv). That runs the real standard-library parser in your browser without launching a shell. Run tests your current code; Check tests the stated sample and extra cases. No real devices, settings, shell commands or customer data are involved.

How to run the complete CLI locally →
JOELEARNS / PYTHON WORKBENCH

Write it. Run it. Understand it.

Build reusable argparse parsers, validate CLI input and test configuration logic with explicit argument lists. Shell execution happens on your computer.

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

Parse a supplied argument list

Define parse_site(argv) using argparse.ArgumentParser with a required --site option. Return the parsed site string, not a Namespace, and do not read sys.argv directly. Use the supplied argv list for 'HQ' and print 'Site: HQ'. The grader calls your function with other site values, and checks that omitting --site is an argparse usage error rather than a guessed default.

EXPECTED OUTPUTSite: HQ
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.