100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

WGU D522 Objective Assessment | Python for IT Automation | ACTUAL EXAM | Questions & Verified Answers | Latest 2025 / 2026 Update – Western Governors University

Rating
-
Sold
-
Pages
47
Grade
A+
Uploaded on
10-12-2025
Written in
2025/2026

WGU D522 Objective Assessment | Python for IT Automation | ACTUAL EXAM | Questions & Verified Answers | Latest 2025 / 2026 Update – Western Governors University

Institution
WGU D522
Course
WGU D522











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
WGU D522
Course
WGU D522

Document information

Uploaded on
December 10, 2025
Number of pages
47
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

WGU D522 Objective Assessment | Python for IT
Automation | ACTUAL EXAM | Questions & Verified
Answers | Latest Update – Western
Governors University

1.​ Which Python data type is best suited for storing a fixed collection of unique IP-address

strings that must remain immutable throughout the script?


A. list


B. set


C. tuple


D. dict


Correct Answer: C


Rationale: A tuple (C) is immutable and can hold unique strings; using it prevents accidental
mutation and conveys intent that the collection should not change. A list (A) is mutable and
allows duplicates. A set (B) is mutable and unordered, making it unsuitable when order must be
preserved. A dict (D) is mutable and keyed, which is unnecessary for a simple collection.


2.​ What is the output of the following snippet?​

print(type(lambda x: x * 2))

,A. <class 'function'>


B. <class 'lambda'>


C. <class 'method'>


D. <class 'int'>


Correct Answer: A


Rationale: In Python a lambda expression creates an anonymous function object whose runtime
type is function (A). There is no separate lambda type (B). It is neither a bound method (C) nor
an integer (D).


3.​ Which statement accurately describes the difference between a Python module and a

package?


A. A module is a single .py file; a package is a directory containing an init.py file and possibly
sub-modules.


B. A module can contain multiple packages; a package cannot contain modules.


C. There is no difference; the terms are interchangeable.


D. A package must be compiled before use, whereas a module is interpreted.


Correct Answer: A

,Rationale: A module is indeed a single file (A), while a package is a directory with an init.py
marker that can contain sub-modules or sub-packages. Option B reverses the relationship. Option
C is false. Option D confuses packages with compiled extensions.


4.​ Which exception will be raised if subprocess.run(['ping', '-c', '1',

'192.168.1.1'], check=True) receives no reply from the target?


A. ConnectionError


B. subprocess.CalledProcessError


C. TimeoutError


D. OSError


Correct Answer: B


Rationale: When check=True the shell return-code becomes an exception; ping returns

non-zero on no reply, raising CalledProcessError (B). ConnectionError (A) is for

sockets. TimeoutError (C) requires a timeout parameter. OSError (D) is too generic and

not triggered here.


5.​ Which re pattern correctly matches an IPv4 dotted-quad address in a log line?



A. r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}'


B. r'[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'

, C. r'\d+.\d+.\d+.\d+'


D. r'(\d{1,3}.){3}\d{1,3}'


Correct Answer: D


Rationale: Pattern D groups three repetitions of digits followed by a dot and then a final digit
group, efficiently matching dotted quads. A and B are verbose but correct; D is more compact. C
is too greedy and could match invalid lengths.


6.​ Which pathlib method returns a new Path object with the file suffix changed?



A. with_suffix()


B. suffix()


C. rename()


D. replace_suffix()


Correct Answer: A


Rationale: Path.with_suffix('.new') (A) returns a new Path object with the extension

altered without renaming the file itself. suffix (B) is a read-only property. rename() (C)

moves/renames the actual file. There is no replace_suffix() (D).



7.​ What is the purpose of if __name__ == '__main__': in a Python automation

script?
$14.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
TommyRicks

Get to know the seller

Seller avatar
TommyRicks Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
1 week
Number of followers
0
Documents
140
Last sold
-
TommyRicks

One stop shop for all all study materials, Study guides,Exams and all assignments and homeworks.

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions