• 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 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. Which module in Python is most commonly used for executing system commands and

interacting with the shell?

A. os.path


B. sys


C. subprocess


D. shutil


Correct Answer: C


Explanation: The subprocess module allows you to spawn new processes and connect to

their input/output/error pipes. It is the recommended tool for running external commands

over older methods like os.system. This functionality is crucial for IT automation tasks that

require interacting with legacy shell scripts or system utilities.


2. What is the primary purpose of the ‘re’ module in a Python automation script?

A. To handle mathematical operations


B. To manage remote server connections


C. To perform regular expression matching and string manipulation


D. To create graphical user interfaces

,Correct Answer: C


Explanation: The re module provides support for regular expressions which are patterns

used to match character combinations in strings. In IT automation, this is frequently used

to parse log files, extract specific data points, and validate user input. Regular expressions

allow for complex searching and text processing that standard string methods cannot easily

handle.


3. When using the ‘requests’ library, which attribute should you check to verify if a GET

request was successful (status code 200)?

A. response.ok


B. response.content


C. response.success


D. response.status_code


Correct Answer: D


Explanation: The status_code attribute returns an integer representing the HTTP status of

the response. A value of 200 indicates success, while codes like 404 or 500 indicate errors.

Checking this value is a standard practice in automation to ensure that network

communications are functioning as expected before processing data.


4. In the context of file handling, what does the ‘with’ statement ensure?

A. The file is encrypted upon closing


B. The file is opened in read-only mode by default

, C. The file is compressed to save space


D. The file is automatically closed after the block of code executes


Correct Answer: D


Explanation: The with statement is a context manager that simplifies resource

management. It ensures that the file is properly closed even if an exception occurs during

the execution of the block. This prevents file corruption and resource leaks, which are

common issues in long-running automation scripts.


5. Which of the following regex patterns would match any single digit from 0 to 9?

A.


B.


C.


D.


Correct Answer: C


Explanation: The equence is a special character in regular expressions that represents any

decimal digit. It is equivalent to the character class [0-9]. Using this shorthand makes

scripts more readable and efficient when validating numeric identifiers or ports.


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

A. The size of the directory


B. A boolean True

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