Lab 2 of 5
Β·
Semi-Guided
Add a get_summary() Method
Objective: Add a get_summary() method to NetworkDevice and call it on three objects.
Instructions
Create a file called lab2.py. Add a get_summary() method to NetworkDevice β write it yourself. The method must include a one-line docstring and return a string in this exact format:
<name> (<device_type>) β <ip> β Site: <site> β VLAN: <vlan>
Create three device objects and print the summary for each.
Your output must match exactly:
sw-core-01 (switch) β 10.1.1.1 β Site: HQ β VLAN: 10
rtr-edge-01 (router) β 10.1.1.254 β Site: HQ β VLAN: 1
fw-dmz-01 (firewall) β 10.1.2.1 β Site: DMZ β VLAN: 100
Run it with python3 lab2.py. Paste your output below and submit.
π‘ Show Hint
def get_summary(self): with a docstring on the next line. Return an f-string using self.name, self.device_type, self.ip, self.site, self.vlan. The β character is an em dash (copy it from the expected output if needed).
Paste Your Output