Python for IT Automation -
D522 PA multiple choice with
correct questions and answers
usr
[COMPANY NAME] [Company address]
, 1. Which function should be used to add data to a file, such as
a network configuration file? Answer: write()
2. Based on the Python code snippet Answer:
def greet(name, greeting = "Welcome to WGU") Answer:
return f"{greeting}, {name}!"
What is the purpose of the first line of code? Answer: To define a function with a
default greeting
3. This Python code snippet returns a syntax error when run Answer:
def multiply_numbers(num1, num2)
result = num1 * num2
return result
num1 = 5
num2 = 8
print(multiply_numbers(num1,
num2))
Which code adjustment will resolve the syntax error? Answer: Add a colon
after def multiply_num-
bers(num1, num2).
4. Based on the Python snippet Answer:
devices = ["router01", "switch01", "modem01", "gateway01",
"printer01"]
Which data structure is being used to store the names for various
types of devices within devices? Answer: List
5. Based on the Python snippet Answer:
2/
7
D522 PA multiple choice with
correct questions and answers
usr
[COMPANY NAME] [Company address]
, 1. Which function should be used to add data to a file, such as
a network configuration file? Answer: write()
2. Based on the Python code snippet Answer:
def greet(name, greeting = "Welcome to WGU") Answer:
return f"{greeting}, {name}!"
What is the purpose of the first line of code? Answer: To define a function with a
default greeting
3. This Python code snippet returns a syntax error when run Answer:
def multiply_numbers(num1, num2)
result = num1 * num2
return result
num1 = 5
num2 = 8
print(multiply_numbers(num1,
num2))
Which code adjustment will resolve the syntax error? Answer: Add a colon
after def multiply_num-
bers(num1, num2).
4. Based on the Python snippet Answer:
devices = ["router01", "switch01", "modem01", "gateway01",
"printer01"]
Which data structure is being used to store the names for various
types of devices within devices? Answer: List
5. Based on the Python snippet Answer:
2/
7