



































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!




































Important: This is an original practice and study bundle aligned to the publicly described D522 Python for IT Automation course and current V2 performance-assessment themes. It does not reproduce confidential/live WGU assessment prompts, answer keys, or submission-ready Task 1/Task 2 responses. Use the current official assessment instructions and rubric for your actual submission.
Practice visual: inventory data feeds automation, which performs network collection and validation before reporting results.
Practice visual: a hostname can be resolved to an address, while reachability and policy compliance remain separate checks.
Practice visual: logical changes can be staged and committed as traceable checkpoints.
Format: answer choices use large dots; the correct choice is marked by a larger green tick inside a box. Each item includes a concise solution rationale.
frozenset
list
set
tuple
Solution: A list is ordered and mutable and may contain duplicate values.
function
define
def
func
Solution: Python uses the def keyword to define a function.
An error
3
Solution: len returns the number of elements in the list, which is three.
is not
Solution: == compares values for equality; = performs assignment.
cleanup
finally
Solution: finally executes after try/except processing in normal control flow.
Loads the os module
Creates an OS object
Installs an operating system
Starts a shell
Solution: import loads the named module so its functions and constants can be used.
chr()
int()
str()
float()
Solution: int('42') converts the text to the integer 42.
string()
reprstr()
str()
text()
Solution: str() produces a string representation of a value.
Only 0 or 1
Any string
A list of flags
True or False
Solution: The bool type has the values True and False.
Solution: The comma makes (5,) a one-element tuple; (5) is just the integer 5.
insert_end()
append()
add()
push()
Solution: append adds one element to the list's end.
delete()
discard()
pop()
remove()
Solution: pop() removes and returns the last element.
3 only
0, 1, 2
Solution: range stops before its endpoint, so range(3) yields 0, 1, and 2.
Solution: A hash begins a single-line Python comment.
Declaring variables
Defining code blocks
Only improving appearance
Ending a statement
Solution: Indentation is syntactically significant and defines blocks.
Empty
Void
None
Null
Solution: None is Python's singleton representing no value.
The value of x
The memory address
The variable name
The type/class of x
Solution: type reports the object's type.
Stores key-value pairs
Fast membership testing for unique items
Preserves duplicates
Solution: Sets are optimized for membership tests and uniqueness.
while item in items
loop(items)
foreach items
for item in items
Solution: Python's for loop naturally iterates over iterable elements.
The loop can run indefinitely
Python automatically stops after 10 iterations
The loop becomes a for loop
The interpreter converts it to recursion
Solution: A true condition with no break or state change can create an infinite loop.
Sorted items
Index and item pairs
Only indexes
Only items
Solution: enumerate yields pairs such as (index, item).
merge()
pair()
zip()
join()
Solution: zip creates tuples containing corresponding elements.
d.has(key)
exists(d,key)
d.contains(key)
key in d
Solution: The in operator tests dictionary keys.
Elements at indexes 1, 2, and 3
Indexes 1 through 4 inclusive
Only index 4
The first four elements
Solution: The stop index is exclusive.
No element
The last element
The first element
The second element
Solution: -1 refers to the last element.
list.order()
order(list)
list.sort()
sorted_in_place(list)
Solution: sort() mutates the list in place.
sort()
order()
rank()
sorted()
Solution: sorted returns a new list containing the sorted values.
Run code when the file is executed directly
Always run code during import
Declare the main class
Start a thread
Solution: The condition distinguishes direct execution from import.
give
return
yield
send
Solution: return exits the function and optionally supplies a value.
An exception
A package
A generator behavior
A dictionary
Solution: yield turns a function into a generator that produces values lazily.
min()
smallest()
low()
Solution: min returns the least item according to ordering.
Create binary files
Open sockets
Build dictionaries concisely from iterable data
Remove all keys
Solution: Dictionary comprehensions create key-value mappings compactly.
w
a
x
r
Solution: r opens an existing file for reading.
w
r
a
x
Solution: w creates or truncates the file before writing.
x
a
w
r
Solution: a writes new content at the end.
It compresses the file
It converts text to JSON
It automatically closes the file
It encrypts the file
Solution: The context manager closes the file when the block exits.
table
spreadsheet
delimited
csv
Solution: Python's standard csv module handles comma-separated data.
A dictionary-like mapping of column names to values
A tuple of integers only
A JSON string
A database cursor
Solution: DictReader maps header fields to row values.
yamljson
json
picklejson
serialize
Solution: The standard json module provides JSON encoding and decoding.
json.parse()
json.read()
json.loads()
json.load()
Solution: loads means load from a string; load reads from a file object.
json.loads()
json.read()
json.fromfile()
json.load()
Solution: load reads JSON from a file-like object.
json.dumps()
json.dump()
json.stringify()
json.encode()
Solution: dumps serializes to a string.
json.tofile()
json.dump()
json.dumps()
json.write()
FileNotFoundError
FileMissing
NoFileError
IOAbsent
Solution: FileNotFoundError is the standard exception for a missing path.
fetch()
read()
readalltext()
getall()
Solution: read() returns the file's contents as a string or bytes.
getlineall()
nextline()
readline()
line()
Solution: readline returns the next line from the file.
It always runs faster
It encrypts logs
It removes duplicates automatically
It reduces peak memory use
Solution: Streaming lines avoids loading the entire file into memory.
Objects, arrays, strings, numbers, booleans, and null
Only tables and rows
Only binary packets
Only Python classes
Solution: JSON defines a small set of structured data types.
empty
null
None
nil
Solution: JSON uses null to represent an absent/null value.
They encrypt the file
They prevent file closure
They define the meaning of each column
They are required to be numeric
Solution: Headers map positional fields to meaningful names.
Delete all backups
Disable error handling
Write directly without checks
Validate the new content and preserve a recoverable copy when appropriate
Solution: Validation and rollback options reduce the risk of corrupting configuration.
re
regexpy
regexp
pattern
Solution: The standard re module implements regular expressions.
Splits every character
Finds a match anywhere in the string
Requires the match at the start only
Replaces every match
Solution: search scans the string for the first location matching the pattern.
Only the last character
Only numeric fields
A match beginning at the start of the string
A match anywhere
Solution: match attempts to match at the beginning.
Only the first match object
A Boolean only
The original string
All non-overlapping matches
Solution: findall returns a list of all matching substrings or groups.
A digit
A letter
Whitespace only
To guarantee the host is reachable
To bypass DNS
To encrypt the address
To catch malformed input early
Solution: Syntax validation prevents malformed input from causing confusing downstream failures.
ipaddress
netparse
iptools
socketaddr
Solution: The ipaddress module supports IPv4/IPv6 address and network objects.
A DNS record
An IPv4 address object
A string only
A socket
Solution: ip_address parses the text into an IPv4Address object.
A network packet
A Git commit
A clear pass/fail result or validated value
A random value
Solution: Clear validation results make calling code predictable.
To make DNS faster
To disable logging
To change IP addresses
To avoid false mismatches from harmless formatting differences
Solution: Normalization can remove irrelevant whitespace/case differences before comparison.
Reporting a problem when the configuration actually meets policy
Missing a real problem
A successful ping
A valid DNS response
Solution: A false positive incorrectly labels compliant data as noncompliant.
A successful login
Failing to report a real problem
Reporting a problem that does not exist
A syntax error
Solution: A false negative misses a condition that should have been detected.
Testing is unnecessary
Regex cannot be automated
Patterns that work on simple examples may fail on unusual valid or invalid inputs
Regex always changes IPs
Solution: Edge cases expose overly permissive or overly restrictive patterns.
Deleting all logs
Installing packages
Resetting passwords
Transforming or rejecting unsafe input before use
Solution: Sanitization reduces risk from malformed or dangerous input.
Avoid the shell when possible and pass arguments as a list
Concatenate raw input into a shell string
Use eval()
Use exec() on the text
Solution: Passing argument lists avoids shell interpretation and injection risks.
It encrypts strings
It can execute arbitrary Python expressions
It only parses JSON
It cannot run code
Solution: eval executes Python expressions and is unsafe with untrusted input.
Delete the record
Ignore the schema
Fail clearly or apply an explicit, documented default
Guess silently
Solution: Explicit failure/default behavior makes automation predictable and auditable.
That a host is reachable
That a Git branch is current
That SMTP is enabled
Solution: AAAA records store IPv6 addresses.
Solution: PTR records map an address to a name in reverse DNS.
Defining an email server
Storing a MAC address
Creating an alias from one name to another name
Storing an IPv4 address
Solution: CNAME creates a canonical-name alias.
Mapping IPv4 addresses
Creating reverse DNS
Defining a subnet mask
Identifying mail servers for a domain
Solution: MX records identify mail exchangers.
resolvectl status
git status
ipconfig /all
route mail
Solution: resolvectl status reports systemd-resolved resolver information where applicable.
Only Windows supports DNS
Different resolver services and configuration mechanisms are used
DNS is not standardized
IP addresses are OS-specific
Solution: Resolver configuration varies by OS and service manager.
To store Git commits
To assign usernames
To forward traffic to destinations outside the local subnet
To resolve hostnames
Solution: The gateway is the next-hop router for off-subnet traffic.
The DNS server password
The Git branch
The SMTP port
Which addresses are local to the subnet
Solution: The mask separates network and host portions of an IP address.
Dynamic network configuration such as IP address and gateway
Git repositories
Email encryption
Python packages
Solution: DHCP can assign addresses and other network settings.
Telnet changes addresses
Its address may change according to the lease
DHCP always uses static addresses
DNS prevents changes
Solution: Dynamic leases can result in different addresses over time.
Checking Git branches
Checking disk compression
Checking whether a target responds to a network probe
Checking whether code is syntactically valid
Solution: Reachability testing determines whether a network target responds.
They are always identical
DNS failure proves the host is offline
Ping failure proves DNS is wrong
They indicate different troubleshooting paths
Solution: A DNS issue can exist even when the host is reachable by IP, and vice versa.
The time taken for data or a response to traverse a path
The number of DNS records
The number of Git commits
The size of a Python list
Solution: Latency measures delay.
Git is corrupted
Some probes or packets failed to reach the destination or return