Lab 2 of 5
Β·
Semi-Guided
Write a Device Status Report to a File
Objective: Write a formatted status report to a text file then read it back and print it.
Instructions
Create a file called lab2.py. Write a script that:
- Writes a device status report to
status_report.txt - Reads the file back and prints every line
Use this device data:
devices = [
{"name": "sw-core-01", "status": "online"},
{"name": "sw-access-01","status": "offline"},
{"name": "rtr-edge-01", "status": "online"},
]
Your output must match exactly:
Report written to status_report.txt
Device Status Report
=========================
sw-core-01 β online
sw-access-01 β offline
rtr-edge-01 β online
Run it with python3 lab2.py. Paste your output below and submit.
π‘ Show Hint
Write to the file using f.write(). After writing, print "Report written..." then open and read the file back with a second "with open" block, printing each line with strip().
Paste Your Output