DevNet Associate 1.3.4 Module 1 Quiz – Python Review (Answers)
1. A student is learning Python using the interactive interpreter mode. The student issues the commands:
>>> routers=[] >>> switches=[] >>> devices=[\"RT1\", \"RT2\", \"RT3\", SW1\", \"SW2\", \"SW3\"] >>> devices=devices + [\"RT4\", \"SW4\"] >>> for i in devices: if \"R\" in i: routers.append(i) else: switches.append(i) >>> switches
What is the result?
- [‘SW4’, ‘SW3’, ‘SW2’, ‘SW1’]
- [‘SW1’, ‘SW2’, ‘SW3’]
- [‘SW4’, ‘SW1’, ‘SW2’, ‘SW3’]
- [‘SW4’]
- [‘SW1’, ‘SW2’, ‘SW3’, ‘SW4’]
2. A student is learning Python in the interactive interpreter mode. The student issues the commands:
>>> devicenames=[\"RT1\", \"RT2\", \"SW1\", \"SW2\"] >>> devicenames[-1]
What is the result?
- [‘RT2’, ‘SW1’, ‘SW2’]
- SW1
- RT1
- SW2
- an error message
3. A developer needs to check the version of the running Python package. Which command should the developer use?
- python3 -i
- python3 -q
- python3 –v
- python3 -V
4. A student is learning Python in the interactive interpreter mode. The student issues the command:
>>> type(True)
What is the data type reported by Python?
- Boolean
- integer
- string
- float
5. Which Python programming function is used to display output?
- if
- for
- while