Lab 1 of 5
Β·
Semi-Guided
Create a NetworkDevice Class
Objective: Write the NetworkDevice class from scratch and test it at the interactive prompt.
Instructions
Open python3 in your terminal. Write the NetworkDevice class yourself β do not copy from the lesson. It needs five attributes: name, ip, device_type, site, and vlan.
Once you have defined the class, create an instance and access three attributes:
sw = NetworkDevice("sw-core-01", "10.1.1.1", "switch", "HQ", 10)
sw.name
sw.ip
sw.vlan
The class definition and instance creation produce no output. The three attribute access lines each print their value.
Paste only the three output lines below and submit.
π‘ Show Hint
class NetworkDevice: then def __init__(self, name, ip, device_type, site, vlan): then five self.x = x lines. At the >>> prompt, define the whole class first, then create the instance, then access each attribute on its own line.
Paste Your Output