Lab 1 of 5
Β·
Guided
Categorize a Device by Its Hostname
Objective: Use if/elif/else to identify a device type from its hostname prefix.
Instructions
Open python3 in your terminal. Run the code block below exactly as written β paste it all in at once or line by line:
hostname = "sw-core-01"
if hostname.startswith("sw"):
print("Cisco Switch")
elif hostname.startswith("rtr"):
print("Router")
elif hostname.startswith("fw"):
print("Firewall")
else:
print("Unknown")
Paste the single line of output below and submit.
π‘ Show Hint
The hostname starts with "sw" so the first condition matches. Python runs that branch and skips the rest.
Paste Your Output