Assessment (OA) & Final Exam Study Guide | Python Programming &
IT Automation Review | Python Fundamentals, Variables & Data
Types, Operators, Conditional Statements, Loops, Functions, Lists,
Tuples, Dictionaries, Sets, Strings, File Handling, CSV Processing,
Exception Handling, Debugging, Modules & Imports, Object-Oriented
Programming, Regular Expressions, Automation Scripting, OS &
System Automation, Subprocess, APIs, Network Automation, Data
Processing, IT Administration & Practical Automation Workflows |
Practice Questions & Detailed Rationales
Question 1: Which of the following best describes the primary role of Python in
IT automation according to the D522 course scope?
A. Replacing all manual administrative tasks with artificial intelligence
B. Automating repetitive IT tasks and processes using readable, maintainable
scripts
C. Creating graphical user interfaces for enterprise applications
D. Compiling C++ programs for network device firmware
E. Designing physical network topologies without software
CORRECT ANSWER: B. Automating repetitive IT tasks and processes using
readable, maintainable scripts
Rationale: The D522 course defines Python for IT Automation as covering
fundamentals, flow control, and automation of IT tasks and processes, with
emphasis on systematic problem solving and administering secure, scalable
networks. Python serves as a scripting language for automating operational
workflows, not for replacing administrative judgment or creating GUIs.
Question 2: A D522 student writes a script to configure 50 network switches.
The script uses a loop to iterate over a device inventory list. Which
programming paradigm does this approach primarily represent?
A. Declarative programming
B. Object-oriented programming
C. Imperative/procedural programming
D. Functional programming
E. Logic programming
,CORRECT ANSWER: C. Imperative/procedural programming
Rationale: Imperative or procedural programming focuses on describing a
sequence of steps to perform a task. A loop that iterates through a device list and
executes configuration steps follows this paradigm. Declarative programming
describes what to accomplish without specifying how, while functional
programming emphasizes immutable data and functions.
Question 3: Which Python feature makes it particularly suitable for IT
automation scripts that must be readable and maintainable by operations
teams?
A. Mandatory type declarations
B. Curly braces for block definition
C. Indentation-based block structure
D. Compilation before execution
E. Semicolon-terminated statements
CORRECT ANSWER: C. Indentation-based block structure
Rationale: Python uses indentation (whitespace at the beginning of a line) to
define blocks of code, unlike languages that use curly braces. This enforced
formatting produces consistent, readable code that is easier for operations teams
to review and maintain. The D522 course emphasizes writing readable Python
that transforms requirements into deterministic logic.
Question 4: An automation engineer needs to store a collection of network
device hostnames that must preserve insertion order and allow duplicate
entries. Which Python data structure is most appropriate?
A. Set
B. Tuple
C. Dictionary
D. List
E. Frozen set
CORRECT ANSWER: D. List
Rationale: A list is an ordered, mutable sequence that allows duplicate values and
preserves insertion order. Sets are unordered and eliminate duplicates. Tuples are
,immutable. Dictionaries store key-value pairs and do not allow duplicate keys.
The D522 course requires choosing appropriate data structures for device
inventory and status tracking.
Question 5: A network engineer is creating a Python script to capture metrics for
different network interfaces, where each set of metrics should be treated as a
single immutable record. Which data structure should be used to store each
recorded metrics snapshot?
A. List
B. Dictionary
C. Tuple
D. Set
E. Bytearray
CORRECT ANSWER: C. Tuple
Rationale: A tuple is an ordered, immutable collection. Once created, its contents
cannot be changed, making it ideal for immutable records such as historical
metrics snapshots. Lists and dictionaries are mutable. Sets are unordered and do
not preserve sequence position, which is often important for metrics records.
Question 6: What is the output of the following Python code?
print(len("Hello World"))
A. 10
B. 11
C. 12
D. 9
E. 5
CORRECT ANSWER: B. 11
Rationale: The len() function returns the total number of characters in a string,
including spaces. "Hello World" contains 5 letters + 1 space + 5 letters = 11
characters. This function is commonly used in automation to validate input
lengths or count devices in inventory lists.
Question 7: A D522 student writes the following code to test type conversion:
x = "5" + "3"
, print(x)
What output does this code produce?
A. 8
B. 53
C. 15
D. TypeError
E. 35
CORRECT ANSWER: B. 53
Rationale: When the + operator is used between two strings, it performs
concatenation rather than arithmetic addition. The strings "5" and "3" are joined
to produce the string "53". To perform arithmetic addition, one or both operands
must first be converted to numeric types using int() or float().
Question 8: Which Python data type is immutable and cannot be changed after
creation?
A. List
B. Dictionary
C. Set
D. Tuple
E. Bytearray
CORRECT ANSWER: D. Tuple
Rationale: Tuples are immutable, meaning their contents cannot be modified
after creation. Lists, dictionaries, and sets are all mutable and can be modified in
place. The D522 course highlights immutable records for historical metrics and
configuration snapshots where data integrity is critical.
Question 9: In the context of D522 IT automation, what is the primary purpose
of using comments in Python source code?
A. To execute hidden configuration instructions
B. To document code and improve readability for human maintainers
C. To increase program execution speed
D. To define variable scope and memory allocation
E. To encrypt sensitive credentials