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

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

Document preview thumbnail
Preview 3 out of 27 pages

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

Content preview

D 522 Exam 3 V2 | D 522 Python for IT Automation
| Actual Q&A with Rationale (D522 Exam 3) |
Western Governors University
1. Which module in Python is specifically designed to provide a way of using operating system

dependent functionality like reading or writing to the file system?

A. sys


B. re


C. os


D. math


Correct Answer: C


Explanation: The os module provides a portable way of using operating system dependent

functionality. This includes tasks such as manipulating file paths and listing directory

contents. It is a fundamental tool for IT automation scripts that interact with the local

environment.


2. When using the ‘re’ module, which character is used to match the start of a string?

A. ^ (Caret)


B. * (Asterisk)


C. $ (Dollar sign)


D. . (Dot)

,Correct Answer: A


Explanation: In regular expressions, the caret (^) character acts as an anchor for the

beginning of a string. This is useful when you want to ensure a specific pattern exists right

at the start of a log line. The dollar sign is used to anchor to the end of a string.


3. Which of the following is the correct way to open a file named ‘data.txt’ for writing, such

that the content is appended to the end of the file?

A. open(‘data.txt’, ‘w’)


B. open(‘data.txt’, ‘r+’)


C. open(‘data.txt’, ‘x’)


D. open(‘data.txt’, ‘a’)


Correct Answer: D


Explanation: The ‘a’ mode stands for append, which ensures that new data is added to the

end of the file without deleting existing content. The ‘w’ mode would overwrite the file

entirely, which is often undesirable in logging. The ‘r+’ mode is for both reading and writing

but starts at the beginning.


4. In the context of IT automation, what does the ‘shutil’ module primarily assist with?

A. High-level file operations like copying and archiving


B. Parsing JSON data from web APIs


C. Performing complex mathematical calculations

, D. Executing unit tests for Python code


Correct Answer: A


Explanation: The shutil module offers high-level operations on files and collections of files.

It is commonly used for copying, moving, and deleting directory trees. This makes it an

essential library for automating system backups and migrations.


5. What will the following regular expression match: [a-zA-Z]+?

A. A sequence of one or more alphabetic characters


B. Any single digit


C. Exactly one uppercase letter


D. Any character that is not a letter


Correct Answer: A


Explanation: The square brackets define a character class including all lowercase and

uppercase letters. The plus sign (+) is a quantifier meaning ‘one or more’ occurrences.

Therefore, it matches strings consisting solely of letters.


6. Which method is used to determine if a specific file exists on a disk using the os.path

module?

A. os.path.verify()


B. os.path.check()


C. os.path.isfile()

Document information

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