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

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

Document preview thumbnail
Preview 3 out of 26 pages

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

Content preview

D 522 Exam 1 V3 | D 522 Python for IT
Automation | Actual Q&A with Rationale
(D522 Exam 1) | Western Governors
University
1. Which module in Python is most commonly used to retrieve command-line arguments

passed to a script?

A. os


B. sys


C. subprocess


D. argparse


Answer: B


Rationale: The sys module provides access to some variables used or maintained by the

interpreter. Specifically, sys.argv is a list in Python, which contains the command-line

arguments passed to the script. This is fundamental for IT automation when scripts need to

handle dynamic input from the shell.


2. When opening a file in Python using open(‘data.txt’, ‘a’), what does the ‘a’ mode signify?

A. Append mode


B. Write mode (overwrite)


C. Read mode

,D. Binary mode


Answer: A


Rationale: The ‘a’ mode stands for append, which allows data to be added to the end of the

file without deleting existing content. If the file does not exist, Python will create a new one.

This is essential for logging tasks where historical data must be preserved.


3. What is the result of the expression 10 // 3 in Python?

A. 3.333


B. Error


C. 1


D. 3


Answer: D


Rationale: The double forward slash represents floor division in Python. It divides the first

number by the second and rounds down to the nearest whole number. This is distinct from

the single slash, which would return a floating-point result.


4. Which data type in Python is unordered, mutable, and does not allow duplicate elements?

A. List


B. Tuple


C. Set


D. Dictionary

, Answer: C


Rationale: A set is a collection which is unordered and unindexed. It is highly efficient for

membership testing and eliminating duplicate entries from other collections. Unlike lists,

sets do not maintain the order in which items were added.


5. In Python, how is a block of code defined for a function or a loop?

A. Curly braces {}


B. Keywords begin and end


C. Parentheses ()


D. Indentation


Answer: D


Rationale: Python uses indentation to indicate the scope of code blocks. This is a unique

feature compared to languages like C++ or Java that use braces. Consistent use of spaces or

tabs is mandatory for the script to execute correctly.


6. Which method is used to remove leading and trailing whitespace from a string?

A. strip()


B. clean()


C. trim()


D. remove()


Answer: A

Document information

Uploaded on
July 16, 2026
Number of pages
26
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.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
12 hours ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed 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