Functions & Reusable Code Clinic.
Six real Python challenges to create small helpers, pass different inputs, return usable values, handle defaults and compose an IT inventory report.
How to use this clinic: Read each requirement and fix the starter function. Call it with multiple inputs, inspect the variable trace and compare the output. Click Check to grade the expected result. All inventories are fictional.
Review Functions & Reusable Code →Write it. Run it. Understand it.
Define reusable helpers, pass different arguments, and return results your caller can use. Verify each case in real Python.
Return a reusable hostname label
The fictional Northstar inventory needs consistent uppercase hostname labels. Fix label_host() so it returns an uppercase trimmed hostname rather than printing it. Store both call results in first and second; print them on separate lines as 'SW-01' and 'AP-02'. The function must work on two different inputs.
SW-01
AP-02Try solving it before asking for help. Hints never show a completed program.
Your printed output and errors will appear here.
Run the code, then step through the executed lines to watch variable values change.
