• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 26 pages
Exam (elaborations)

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

Document preview thumbnail
Preview 3 out of 26 pages

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

Content preview

D 522 Exam 4 V1 | D 522 Python for IT Automation
| Actual Q&A with Rationale (D522 Exam 4) |
Western Governors University
1. When using the Python ‘re’ module, which character is used to match the start of a string?

A. ^


B. $


C. *


D. ?


Correct Answer: A


Explanation: The caret symbol (^) is used in regular expressions to anchor the match to

the beginning of a string. This is crucial for identifying lines in logs that start with specific

patterns. Using the ‘$’ symbol would instead anchor the match to the end of the string.


2. In the ‘subprocess’ module, what is the purpose of the ‘capture_output=True’ argument?

A. It terminates the process if it takes too long.


B. It allows the script to read the standard output and standard error of the command.


C. It causes the process to run in the background.


D. It automatically deletes the output files created by the command.


Correct Answer: B

,Explanation: Setting capture_output to True allows the Python script to store the result of

the command in the completed process object. This allows for further processing of the

command’s results within the script logic. Without this, the output is directed to the system

console by default.


3. Which method from the ‘unittest’ module is used to verify that two values are the same?

A. assertTrue()


B. assertEqual()


C. assertMatch()


D. assertVerify()


Correct Answer: B


Explanation: The assertEqual method is the standard way to check for equality between

an expected result and the actual result in a test case. It is part of the unittest.TestCase class

provided by the standard library. If the values do not match, the test will fail and report the

discrepancy.


4. What is the default log level for the Python ‘logging’ module?

A. DEBUG


B. WARNING


C. INFO


D. ERROR

, Correct Answer: B


Explanation: By default, the logging module is configured to only display messages with a

level of WARNING or higher. This means that DEBUG and INFO messages will be

suppressed unless the configuration is explicitly changed. Understanding log levels helps

developers manage the verbosity of automation scripts.


5. Which function is used to convert a Python dictionary into a JSON-formatted string?

A. json.load()


B. json.dumps()


C. json.loads()


D. json.dump()


Correct Answer: B


Explanation: The json.dumps() function takes a Python object and returns its JSON string

representation. Note that the ‘s’ in ‘dumps’ stands for ‘string’. This is commonly used when

sending data to web APIs or storing configuration as text.


6. What does the ‘os.path.exists()’ function return if a file is found?

A. The file path as a string


B. A boolean True


C. The file size


D. A file object

Document information

Uploaded on
September 24, 2026
Number of pages
26
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$19.38

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.
Shinnie
3.6
(7)
Sold
27
Followers
0
Items
4868
Last sold
1 week 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