• 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 28 pages
Exam (elaborations)

D 522 Exam 4 V3 | 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 V3 | D 522 Python for IT Automation | Actual Q&A with Rationale (D522 Exam 4) | Western Governors University

Content preview

D 522 Exam 4 V3 | D 522 Python for IT Automation
| Actual Q&A with Rationale (D522 Exam 4) |
Western Governors University
1. When using the ‘re’ module to validate a configuration file, which function should be used

to find all non-overlapping matches of a pattern in a string?

A. re.search()


B. re.split()


C. re.match()


D. re.findall()


Correct Answer: D


Explanation: The re.findall() function is designed to return all non-overlapping matches of

a pattern in a string as a list of strings. This is particularly useful in IT automation when

extracting multiple instances of data like IP addresses or error codes from logs. Unlike

re.search(), which only finds the first occurrence, findall provides a comprehensive

collection of all matches encountered.


2. An automation script needs to check if a specific directory exists before creating a log file.

Which method from the ‘os’ module is most appropriate?

A. os.path.isfile()


B. os.path.isdir()

,C. os.mkdir()


D. os.getcwd()


Correct Answer: B


Explanation: The os.path.isdir() function returns True if the specified path is an existing

directory. Using this check prevents the script from crashing when trying to access or

create files in non-existent locations. It is a fundamental safety practice in script

development to verify environment states before executing file I/O operations.


3. Which method is used to send a specific signal to a process using the ‘subprocess’ module?

A. Popen.kill()


B. Popen.terminate()


C. Popen.send_signal()


D. Popen.wait()


Correct Answer: C


Explanation: The Popen.send_signal() method allows a script to send a specific signal, such

as SIGTERM or SIGKILL, to a running subprocess. This provides granular control over

process management and lifecycle within an automation workflow. Relying on this method

ensures that external tasks can be managed dynamically based on system requirements.


4. In Python, how is the ‘with’ statement beneficial when handling file operations for IT logs?

A. It speeds up the file reading process significantly.

, B. It automatically closes the file after the block of code is executed.


C. It encrypts the log data to ensure security.


D. It allows the file to be edited by multiple users simultaneously.


Correct Answer: B


Explanation: The ‘with’ statement acts as a context manager that ensures resources are

properly cleaned up. Specifically, it guarantees that a file is closed immediately after the

nested block finishes, even if an exception occurs. This is vital in automation to prevent

resource leaks and file locking issues on production servers.


5. Which regular expression character is used to match the start of a string in a log entry?

A. ^


B. *


C. $


D. +


Correct Answer: A


Explanation: The caret symbol (^) is a regex anchor that matches the position at the very

beginning of a string or line. It is commonly used in IT automation to ensure that a pattern,

such as a timestamp, appears at the start of a log line. Without this anchor, the regex might

return false positives from the middle of the text.

Document information

Uploaded on
September 24, 2026
Number of pages
28
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