




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























Core Domains: Python Fundamentals and Syntax Network Automation and Device Discovery DNS Configuration Audit and Analysis Telnet/SSH Connectivity and Command Execution CSV and JSON Data Processing Error Handling and Exception Management Python for System Administration Scripting for IT Operations API Integration and Helpdesk Automation GitLab and Version Control Workflows Evidence Collection and Submission Requirements This comprehensive performance assessment bundle is designed to prepare students for the WGU D522 Python for IT Automation (WEN1) Task 1 and Task 2 Performance Assessments. The examination evaluates fundamental and applied Python programming knowledge for IT automation, including network device discovery, DNS configuration auditing, remediation scripting, helpdesk API integration, CSV monitoring, and evidence collection. Questions are structured to assess both theoretical understanding and practical coding skills required for successful completion of the performance assessments. Each question includes a verified correct answer and a detailed rationale to reinforce learning and support exam preparation. The guide reflects the most current 2026 curriculum standards for WGU's D522 course.
Question 1 Which programming paradigm focuses on describing a sequence of steps to perform a task, making it foundational to scripting and automation? A. Object-Oriented Programming B. Functional Programming C. Imperative/Procedural Programming D. Declarative Programming C. Imperative/Procedural Programming RATIONALE: Imperative or procedural programming is characterized by a step-by-step sequence of instructions that change the program's state. This approach is foundational to scripting and automation, where tasks are broken down into a series of explicit commands executed in order. Question 2 What is a key trait of Object-Oriented Programming (OOP) that is particularly effective for complex automation systems? A. Describes what the program should accomplish without specifying how B. Organizes code around objects that encapsulate data and behavior C. Defines a set of logical conditions and lets the system deduce solutions D. Focuses on using functions and immutable data for computation B. Organizes code around objects that encapsulate data and behavior RATIONALE: Object-Oriented Programming models real-world entities as "objects" that contain both data (attributes) and behavior (methods). This encapsulation promotes modularity, reusability, and is particularly effective for complex automation systems where components like network devices or servers can be represented as objects. Question 3 Python is known for being a multi-paradigm language. Which paradigms does Python support?
Question 6 What will be the result of the expression 5 + 3 * 2 in Python? A. 16 B. 13 C. 11 D. 10 C. 11 RATIONALE: Python follows standard operator precedence rules. The multiplication operator (*) has higher precedence than addition (+), so 3 * 2 is evaluated first to yield 6, and then 5 + 6 results in 11. Question 7 What is the result of the expression 3 ** 2 in Python? A. 6 B. 8 C. 9 D. 12 C. 9 RATIONALE: The ** operator in Python performs exponentiation. Thus, 3 ** 2 is equivalent to 3 raised to the power of 2, which equals 9. Question 8 What is the output of print("5" + "3") in Python? A. 8 B. "53" C. 53 D. Error C. 53 RATIONALE: The + operator concatenates strings. "5" + "3" results in the string "53". The quotes are not printed; they are used to denote the string in the code.
Question 9 What is the output of print("5" * 3) in Python? A. 15 B. "555" C. 555 D. Error B. "555" RATIONALE: When a string is multiplied by an integer, Python repeats (concatenates) the string that many times. "5" * 3 results in "555". Question 10 What does the is operator do in Python? A. Checks if two values are equal B. Checks if two variables refer to the same object in memory C. Checks if a variable is of a certain type D. Checks if a value is contained in a sequence B. Checks if two variables refer to the same object in memory RATIONALE: The is operator performs an identity comparison, returning True if both operands reference the same object in memory. This is distinct from the == operator, which checks for value equality. Question 11 What is the result of bool(0) in Python? A. True B. False C. 0 D. Error B. False 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.
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. Use in scripts to automate user setup and directory traversal. Question 15 Which function is used to determine the length of a sequence such as a list, string, or tuple in Python? A. size() B. length() C. len() D. count() C. len() RATIONALE: The len() function is the built-in Python function used to return the number of items in a sequence or collection. size() is not a built-in Python function (it's used in other languages like Java), length() is not a Python built-in, and count() returns the number of occurrences of a specific element. Question 16 When building a network inventory report, you need to include the device model, OS version, and serial number. Which approach is most appropriate for multi-vendor support? A. Paramiko with SSH and manual parsing of 'show version' output B. Netmiko with SSH and TextFSM templates to parse structured output C. SNMP with pysnmp and OIDs for sysDescr, sysObjectID, and entPhysicalSerialNum D. Nornir with Netmiko and NAPALM to retrieve facts D. Nornir with Netmiko and NAPALM to retrieve facts RATIONALE: Nornir provides inventory management and NAPALM offers vendor-agnostic facts retrieval, making it efficient and scalable. Paramiko requires extensive manual parsing, Netmiko lacks orchestration, and SNMP may not provide all details on all vendors. Question 17 What is the purpose of the EXPECTED_DNS variable in a DNS audit script?
A. It stores the IP address of the DNS server that the configuration should be using B. It stores the current DNS configuration C. It stores the device's hostname D. It stores the device's IP address A. It stores the IP address of the DNS server that the configuration should be using RATIONALE: The EXPECTED_DNS variable holds the approved DNS IP address that the device's configuration should be using, against which the current configuration is compared. Question 18 What is the purpose of the resolvectl status command as a fallback in a DNS audit script? A. To check the device's uptime B. To provide an alternative method to retrieve DNS configuration if resolvectl dns fails C. To restart the DNS resolver D. To list all network interfaces B. To provide an alternative method to retrieve DNS configuration if resolvectl dns fails RATIONALE: If the resolvectl dns command cannot be verified, the script falls back to resolvectl status to read the current resolver state. Question 19 Which data type would be most appropriate for storing a collection of unique IP addresses in Python? A. List B. Tuple C. Set D. Dictionary C. Set RATIONALE: A set is the most appropriate data type for storing unique IP addresses because sets automatically eliminate duplicate values. Lists and tuples allow duplicates, and while dictionaries can store unique keys, a set is the most direct and efficient choice for a collection of unique values without associated data. Question 20
Question 23 What does the bool() function return for an empty string? A. True B. False C. None D. Error B. False RATIONALE: In Python, empty sequences (including strings) are considered False in a boolean context. Non-empty strings are True. Question 24 Which operator is used for exponentiation in Python? A. ^ B. ** C. // D. * B. ** RATIONALE: ** is the exponentiation operator (e.g., 2**3 = 8). ^ is bitwise XOR, not exponentiation. Question 25 What is the output of print(3 * "Hi") in Python? A. HiHiHi B. 3Hi C. Hi D. TypeError A. HiHiHi RATIONALE: The * operator repeats a string when used with an integer. "Hi" * 3 results in "HiHiHi". Question 26
What data type is produced by the input("Enter age: ") function in Python? A. int B. float C. str D. bool C. str RATIONALE: The input() function always returns a string, regardless of what the user types. Use int() or float() to convert the input to a numeric type. Question 27 Which of the following statements will cause a NameError in Python? A. print(x) where x = 5 defined earlier B. print(y) where y has not been defined C. print("hello") D. print(5) B. print(y) where y has not been defined RATIONALE: A NameError occurs when a variable name is used but has not been defined. Common causes include typos in variable names. Question 28 Which escape sequence represents a tab character in Python? A. \t B. \n C. \r D. \b A. \t RATIONALE: \t is the escape sequence for a tab character. \n is newline, \r is carriage return, \b is backspace. Question 29
Question 32 What error is present in the following Python snippet? port = input("Secure Web access? Y/N: ") if port == "Y" print("Use port 443.") else print("Use port 80.") A. Missing colons at the end of the if and else lines B. Incorrect indentation C. Missing parentheses D. Invalid variable name A. Missing colons at the end of the if and else lines RATIONALE: In Python, colons are required at the end of if, elif, and else statements. The corrected code would have if port == "Y": and else:. Question 33 A developer is creating a Python script to capture metrics for different network interfaces on a router, with each set of metrics treated as a single, immutable record. Which data structure should be used? A. List B. Tuple C. Dictionary D. Set B. Tuple RATIONALE: Tuples are immutable, ordered collections that are suitable for storing records that should not be modified, such as a snapshot of network interface metrics at a given point in time. Question 34 Which Python built-in function is used to list the names in the current scope or attributes of an object? A. type() B. dir() C. help() D. id()
B. dir() RATIONALE: The dir() function lists the names in the current scope or attributes of an object. It is useful for exploring what methods and attributes are available on an object. Question 35 What is the primary characteristic of Python variables? A. Variables must be declared with a type before use B. Variables are created as soon as a value is assigned to them C. Variables must be initialized with a specific data type D. Variables are immutable once created B. Variables are created as soon as a value is assigned to them RATIONALE: Python variables are dynamically typed and are created when a value is assigned to them. No explicit declaration is required. Question 36 What are the rules for variable names in Python? A. Can contain special characters B. Must start with a number C. Cannot be a Python keyword D. Can contain spaces C. Cannot be a Python keyword RATIONALE: Variable names must start with a letter or underscore, cannot start with a number, cannot contain special characters or spaces, and cannot be Python keywords (such as and, as, def, else, etc.). Question 37 Which function should be used to add data to a file, such as a network configuration file? A. read() B. write() C. append() D. add()
RATIONALE: IT automation involves automating repetitive tasks such as monitoring server statuses and generating alerts. This is a practical application of Python in IT operations. Question 41 What is the purpose of the csv.DictReader in Python? A. To write CSV files B. To use the first line as header keys and return each row as a dictionary C. To read files as a list of lists D. To validate CSV data B. To use the first line as header keys and return each row as a dictionary RATIONALE: csv.DictReader can use the first line as header keys and return each row as a dictionary, making it easier to access data by column name. Question 42 Which Python module is used for writing to CSV files? A. csv.reader B. csv.writer C. json.dump D. pickle.dump B. csv.writer RATIONALE: csv.writer is used for writing to CSV files. It provides methods to write rows of data to a CSV file. Question 43 What is the purpose of logging in a Python automation script? A. To print debug statements only B. To provide a detailed record of script actions, errors, and successes for auditing and troubleshooting C. To slow down script execution D. To output data to CSV
B. To provide a detailed record of script actions, errors, and successes for auditing and troubleshooting RATIONALE: Logging provides a detailed record of script actions, errors, and successes, which is essential for auditing and troubleshooting remediation activities. Question 44 What is the purpose of the "validation" phase in the network remediation workflow? A. To confirm that remediation changes were successfully applied and DNS resolution is functioning correctly B. To discover new network devices C. To create backup files D. To generate audit reports A. To confirm that remediation changes were successfully applied and DNS resolution is functioning correctly RATIONALE: Validation involves verifying that the applied changes have successfully corrected the issue and that the system is functioning as expected. Question 45 In a Python network automation script using NAPALM, you retrieve the ARP table from a device and 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 B. There is a possible ARP spoofing attack or IP conflict on the network RATIONALE: Multiple MAC addresses for the same IP typically indicate an IP conflict or ARP spoofing. Different interfaces would have different IPs, and IPv4/IPv6 show different IPs, not the same IP with multiple MACs. Question 46
Question 49 To get the current working directory in a Python script, which function should be used? A. os.getcwd() B. sys.path[0] C. pwd.current() D. dir.getcwd() A. os.getcwd() RATIONALE: os.getcwd() returns the absolute path of the current working directory and is reliable across operating systems. It is useful for logging script location and troubleshooting. Question 50 For scheduling system tasks in Python, which library is preferred? A. time.sleep() B. sched C. APScheduler D. cron C. APScheduler RATIONALE: APScheduler handles cron-like jobs with persistence and is more flexible than basic time functions. It automates backups and scheduled tasks. Question 51 To check if a file exists before system operations, which method should be used? A. os.path.isfile(path) B. open(path, 'r') C. file.exists() D. path.check() A. os.path.isfile(path) RATIONALE: os.path.isfile(path) checks if a file exists at the specified path. This prevents errors when attempting to open or manipulate files that may not exist. Question 52
What is the purpose of the telnetlib module in Python network automation? A. To establish SSH connections B. To establish Telnet connections to network devices C. To parse DNS configurations D. To read CSV files B. To establish Telnet connections to network devices RATIONALE: telnetlib.Telnet(host, port) establishes a Telnet connection to a network device, allowing command execution for automation and auditing tasks. Question 53 When creating a Python script for DNS audit, what does the DEVICE_PORTS dictionary typically store? A. Device hostnames B. The TCP ports associated with each device for Telnet connectivity C. DNS server IP addresses D. Device passwords B. The TCP ports associated with each device for Telnet connectivity RATIONALE: The DEVICE_PORTS dictionary in a DNS audit script maps device names to their Telnet ports, allowing the script to connect to each device for auditing. Question 54 What is the purpose of the CONNECT_TIMEOUT constant in a network automation script? A. To define the maximum time to wait for a command to execute B. To define the maximum time to wait for a connection to be established C. To define the number of retry attempts D. To define the delay between commands B. To define the maximum time to wait for a connection to be established RATIONALE: The CONNECT_TIMEOUT constant specifies the maximum time (in seconds) to wait for a connection to be established, preventing indefinite blocking. Question 55