Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 28 pages
Exam (elaborations)

D 522 Exam 4 V2 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 4) | Western Governors University

Document preview thumbnail
Preview 3 out of 28 pages

D 522 Exam 4 V2 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 4) | Western Governors University

Content preview

D 522 Exam 4 V2 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 4) | Western Governors
University
1. When using the Python ‘subprocess’ module, which argument should be set to ‘True’ in the

run() function to capture the standard output and standard error for further processing?

A. capture_output


B. shell


C. check


D. timeout


Answer: A


Rationale: The ‘capture_output’ argument is used to capture the output of the command

execution in the subprocess.run() function. When set to True, it ensures that both stdout

and stderr are captured and stored in the returned CompletedProcess object. This is

essential for automation scripts that need to parse the results of external system

commands.


2. Which regular expression character is used to match the beginning of a string?

A. ^


B. *

,C. $


D. +


Answer: A


Rationale: The caret symbol (^) is a meta-character used in regular expressions to signify

the start of a string or line. It ensures that the pattern search begins exactly at the first

character position. Understanding these anchors is fundamental for valid string parsing

and data extraction tasks.


3. In the ‘requests’ library, which HTTP method is typically used to update an existing

resource with new data?

A. PUT


B. GET


C. DELETE


D. HEAD


Answer: A


Rationale: The PUT method in HTTP protocol is specifically designed to replace an existing

resource or create it if it does not exist at a specific URI. In Python’s requests library,

‘requests.put()’ is used to send this type of request to a REST API. This method is

idempotent, meaning multiple identical requests should have the same effect as a single

one.

, 4. Which method from the ‘os’ module should an IT professional use to delete a file that is no

longer needed by an automation script?

A. os.rmdir()


B. os.delete()


C. os.clear()


D. os.remove()


Answer: D


Rationale: The ‘os.remove()’ function is used to delete a file path from the system. It is

important to note that ‘os.rmdir()’ is used specifically for empty directories, not files. Using

the correct removal function prevents execution errors when managing local file system

storage.


5. What is the purpose of the ‘json.loads()’ function in Python?

A. To convert a Python dictionary into a JSON string.


B. To read a JSON file and load it into a Python object.


C. To parse a JSON-formatted string and convert it into a Python dictionary.


D. To validate the syntax of a JSON schema.


Answer: C


Rationale: The ‘json.loads()’ function stands for ‘load string’ and is used to deserialize a

string containing JSON data into a Python object, such as a dictionary or list. This is distinct

Document information

Uploaded on
July 16, 2026
Number of pages
28
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$17.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ScholarsAscend
3.7
(77)
Sold
453
Followers
39
Items
29361
Last sold
11 hours ago




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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions