Docsity

WGU D522 Task 1 Performance Assessment Guide | Python Network Automation, Device Inventory, Exams of Information Technology

Partial preview of the text

Download WGU D522 Task 1 Performance Assessment Guide | Python Network Automation, Device Inventory and more Exams Information Technology in PDF only on Docsity!

C. Tuple, because it is ordered and immutable D. Set, because it is unordered and contains unique elements Correct Answer: C Rationale: A tuple is an ordered, immutable sequence, making it ideal for representing a fixed set of metrics that should not be modified, ensuring data integrity for a snapshot record. Source: WGU D522 Study Guide; Data Structures Module Question 3: Which Python data structure would be most appropriate for storing a record of device names and their corresponding IP addresses? A. List, because it is ordered and changeable B. Dictionary, because it stores key-value pairs C. Tuple, because it is ordered and immutable D. Set, because it is unordered and contains unique elements Correct Answer: B Rationale: Values are accessed using descriptive keys rather than numeric indexes, making dictionaries ideal for representing relationships such as device names and IP addresses. This structure improves code clarity and maintainability in automation tasks. Source: WGU D522 Study Guide; Data Structures Module Question 4: A programmer writes the following code: python def multiply_numbers(num1, num2) result = num1 * num return result Which code adjustment will resolve the syntax error? A. Add a colon after def multiply_numbers(num1, num2) B. Remove the return statement

C. Add parentheses around the parameters D. Change def to function Correct Answer: A Rationale: In Python, function definitions require a colon at the end of the def statement line. The correct syntax is def multiply_numbers(num1, num2): followed by an indented block. Source: WGU D522 Study Guide; Python Functions Module Question 5: Based on the Python snippet: python value = input("Enter a number: ") result = int(value) + 10 print(result) What purpose does result = int(value) + 10 serve? A. Converts the user's input into a string and concatenates it B. Converts the user's input into an integer and adds 10 C. Multiplies the user's input by 10 D. Divides the user's input by 10 Correct Answer: B Rationale: The int() function converts the user's string input into an integer data type. The + 10 then performs addition, resulting in the numeric sum. Source: WGU D522 Study Guide; Type Conversion Module Question 6: What is the output of this Python code? python numbers = [ 1 , 2 , 3 ] numbers[ 0 ] = 10 print(numbers)

Correct Answer: C Rationale: Tuples are created using parentheses () in Python. Square brackets [] create lists, curly braces {} create sets or dictionaries, and angle brackets are not used for Python data structures. Source: WGU D522 Study Guide; Tuples Module Question 9: Which characteristics are associated with tuples in Python? A. Ordered and changeable B. Ordered and unchangeable C. Unordered and unchangeable D. Unordered and changeable Correct Answer: B Rationale: Tuples are ordered sequences that are immutable (unchangeable) once created. This makes them suitable for representing fixed, read-only data records. Source: WGU D522 Study Guide; Tuples Module Question 10: What is the result of bool(0) in Python? A. True B. False C. 0 D. Error Correct Answer: B Rationale: In Python, the integer 0 is considered a "falsey" value. When passed to the bool() constructor, it evaluates to False. Other falsey values include None, empty sequences, and empty strings. Source: WGU D522 Study Guide; Boolean Values Module

Question 11: What does len("Hello") return? A. 4 B. 5 C. 6 D. Error Correct Answer: B Rationale: The len() function returns the number of characters in a string. The string "Hello" contains five characters: H, e, l, l, o. Source: WGU D522 Study Guide; String Functions Module Question 12: Which Python module is used to interact with the operating system for tasks like file permissions or environment variables? A. sys B. os C. json D. subprocess Correct Answer: B Rationale: The os module provides functions like os.chmod() for permissions and os.environ for variables, essential for cross-platform system tasks in IT automation. Source: WGU D522 Study Guide; OS Interaction Module Question 13: The shutil module is best suited for which type of operation? A. Mathematical calculations B. High-level file operations like copying directories C. Network communications D. Database connections Correct Answer: B Rationale: shutil.copytree() recursively copies folders, ideal for backup automation in deployment scripts.

Question 16: What error is present in this Python snippet? python port = input("Secure Web access? Y/N: ") if port == "Y" print("Use port 443.") else print("Use port 80.") A. Missing parentheses B. Missing colons at the end of the if and else lines C. Incorrect indentation D. Missing quotation marks Correct Answer: B Rationale: In Python, both if and else statements require a colon at the end of the line. The correct syntax is if port == "Y": and else:. Source: WGU D522 Study Guide; Control Flow Module Question 17: A Python script attempts to divide two numbers provided by user input. If the user enters a non-numeric value or attempts to divide by zero, the script crashes. Which error handling structure should be used? A. if-else statements B. try-except blocks C. while loops D. for loops Correct Answer: B Rationale: Proper error handling using try-except blocks catches exceptions like ZeroDivisionError and ValueError, preventing crashes and providing meaningful feedback to users. Source: WGU D522 Study Guide; Error Handling Module

Question 18: What exception is raised when trying to open a non-existent file for reading? A. IOError B. FileNotFoundError C. PermissionError D. OSError Correct Answer: B Rationale: In Python 3, FileNotFoundError (a subclass of OSError) is raised when a file does not exist and is opened in read mode. Source: WGU D522 Study Guide; File I/O Module Question 19: Which block is guaranteed to execute regardless of whether an exception occurs in a try-except structure? A. except B. else C. finally D. else Correct Answer: C Rationale: The finally block always executes after the try/except blocks, even if an exception is not caught or if a return statement is encountered. Source: WGU D522 Study Guide; Exception Handling Module Question 20: What is the output of this code? python import math a = 12 b = math.sqrt( 121 ) if a > b: print("Greater than b") elif a < b:

Rationale: try-except structures are used to handle exceptions such as connection failures, authentication issues, and command timeouts, allowing the script to continue processing other devices. Source: WGU D522 Performance Assessment Guide; Error Handling Module Question 23: Which keyword is used to raise an exception manually in Python? A. throw B. raise C. except D. error Correct Answer: B Rationale: raise is used to manually raise an exception in Python (e.g., raise ValueError("Invalid input")). Source: WGU D522 Study Guide; Exception Handling Module Question 24: What is the correct way to handle a timeout when connecting to a network device? A. Use time.sleep() before connecting B. Set a timeout parameter in the connection function C. Use an infinite loop with a counter D. Ignore timeouts and assume the connection will succeed Correct Answer: B Rationale: Setting a timeout parameter in connection functions prevents indefinite blocking and allows the script to handle unresponsive devices gracefully. Source: WGU D522 Task 1 Study Guide; Connectivity Testing Module

Question 25: What is the purpose of response.raise_for_status() when making API requests? A. To raise an exception for HTTP error responses (4xx, 5xx) B. To parse the JSON response C. To send the request again D. To log the request Correct Answer: A Rationale: response.raise_for_status() raises an exception for HTTP error responses, allowing for consistent error handling when API calls fail. Source: WGU D522 Study Guide; HTTP Error Handling Module

SECTION 3: NETWORK DEVICE INVENTORY &

DISCOVERY (Questions 26-35)

Question 26: In a Python network automation script using NAPALM, you retrieve the ARP table from a device. You notice that some IP addresses appear multiple times with different MAC addresses. What does this indicate? A. The device has multiple interfaces and each MAC is associated with a different interface B. There is a possible ARP spoofing attack or IP conflict on the network C. The ARP table is corrupted and needs to be cleared D. The device is running both IPv4 and IPv6, causing duplicate entries Correct Answer: B Rationale: Multiple MAC addresses for the same IP typically indicate an IP conflict or ARP spoofing. Different interfaces would have different IP addresses, not the same IP with multiple MACs. Source: WGU D522 Study Guide; Network Security Module Question 27: When building a network inventory report, you need to include the device model, OS version, and serial number. Which combination of Python libraries and protocols is most appropriate for multi-vendor

Correct Answer: A Rationale: TextFSM templates parse semi-structured command output from network devices into structured data, making it easier to extract specific fields like device model and OS version. Source: WGU D522 Study Guide; TextFSM Module Question 30: You need to write a Python script that uses Netmiko to connect to multiple devices from a CSV inventory file. Which step is essential before iterating through the devices? A. Open and parse the CSV file to extract device credentials B. Install Netmiko using pip install netmiko C. Configure each device with the correct SSH settings D. Check if the devices are powered on Correct Answer: A Rationale: Before iterating through the devices, you must open and parse the CSV inventory file to extract device information such as IP addresses and credentials. Source: WGU D522 Task 1 Study Guide; Device Inventory Module Question 31: What is the purpose of validating device connectivity before attempting to audit DNS configuration? A. To ensure the device is reachable and the script can execute commands B. To confirm the device is powered on C. To verify the device has a valid IP address D. To check the device's operating system version Correct Answer: A Rationale: Validating connectivity ensures the device is reachable and the script can successfully connect to execute audit commands. Source: WGU D522 Performance Assessment Guide; Device Validation Module

Question 32: In the D522 Task 1 DNS audit script, what does the discover_port() function do? A. Establishes a Telnet connection to the device B. Performs a lightweight TCP probe before starting a Telnet session C. Parses the DNS configuration from the device D. Generates the audit report Correct Answer: B Rationale: The discover_port() function performs a lightweight TCP probe before starting a Telnet session to verify the port is open and accepting connections. Source: WGU D522 Task 1 Source Code; Connectivity Module Question 33: A Python script processes a CSV inventory file. The script runs multiple times and reads the file each time. Which optimization would be most appropriate? A. Read the CSV file once at the beginning and store it in a data structure B. Read the CSV file each time it is needed C. Convert the CSV to a JSON file D. Store the CSV data in a database Correct Answer: A Rationale: Reading the CSV file once at the beginning of the script and storing the data in a variable improves performance and reduces disk I/O. Source: WGU D522 Study Guide; File Processing Module Question 34: Which Python module is commonly used for SSH connections in network automation? A. telnetlib B. paramiko

Rationale: The resolvectl dns command is used to retrieve the current DNS server configuration for a specific network interface on Linux systems using systemd-resolved. Source: WGU D522 Task 1 Source Code; DNS Audit Module Question 37: What is the purpose of the EXPECTED_DNS constant in the D DNS audit script? A. To store the IP address of the DNS server that should be configured on all devices B. To store the IP address of the local machine C. To store the IP address of the gateway D. To store the IP address of the DHCP server Correct Answer: A Rationale: The EXPECTED_DNS constant stores the IP address of the DNS server that should be configured on all network devices. The audit compares each device's DNS configuration against this value. Source: WGU D522 Task 1 Source Code; DNS Audit Module Question 38: When parsing resolvectl dns output, the script extracts IP addresses using: A. JSON parsing B. Regular expressions C. CSV parsing D. XML parsing Correct Answer: B Rationale: The audit script uses regular expressions to parse the command output and extract DNS IP addresses from the CLI response. Source: WGU D522 Task 1 Source Code; CLI Parsing Module

Question 39: According to the D522 Task 1 decision logic, when is a DNS configuration considered "VALID"? A. When no DNS servers are detected B. When the expected DNS appears in the parsed addresses C. When the device fails to respond to Telnet D. When the DNS servers are all IPv6 addresses Correct Answer: B Rationale: The DNS configuration is classified as "VALID" when the expected DNS IP address appears in the parsed addresses from the device. Source: WGU D522 Performance Assessment Guide; DNS Classification Module Question 40: What is the purpose of the AUDIT_COMMANDS tuple in the DNS audit script? A. To store the list of commands that will be executed on each device B. To store the list of expected DNS responses C. To store the list of device names D. To store the list of port numbers Correct Answer: A Rationale: The AUDIT_COMMANDS tuple stores the commands that will be executed on each device to retrieve DNS information, typically resolvectl dns and resolvectl status. Source: WGU D522 Task 1 Source Code; Command Execution Module Question 41: In the D522 Task 1 audit script, what does the read_until_any() function do? A. Reads until a known shell/login prompt or until the timeout expires B. Reads all available data from the socket C. Reads data until a specific character is encountered D. Reads data indefinitely Correct Answer: A