• 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 4 out of 95 pages
Exam (elaborations)

WGU D522 Python for IT Automation OA

Document preview thumbnail
Preview 4 out of 95 pages

WGU D522 Python for IT Automation OA

Content preview

WGU D522 Python for IT Automation OA
Exam Prep
200 Questions & Answers with Rationales

SECTION 1: PYTHON FUNDAMENTALS (Questions 1-40)
Question 1
What is the output of the following code?
python
x=5
y=2
print(x // y)
A) 2.5
B) 2
C) 3
D) 2.0
Answer: B) 2
Rationale: The // operator performs floor division, which returns the integer
quotient rounded down. 5 // 2 = 2 (not 2.5). This is different from / which returns a
float.


Question 2
Which of the following is NOT a valid variable name in Python?
A) _my_var
B) myVar2
C) 2myVar
D) my_var

,Answer: C) 2myVar
Rationale: Python variable names cannot start with a number. They must start with
a letter (a-z, A-Z) or underscore (_). The subsequent characters can be letters,
numbers, or underscores.


Question 3
What is the result of bool([]) in Python?
A) True
B) False
C) Error
D) None
Answer: B) False
Rationale: In Python, empty sequences (lists, tuples, strings), empty dictionaries,
and the number 0 evaluate to False in a boolean context. [] is an empty list, so it
evaluates to False.


Question 4
Which method is used to add an element to the end of a list?
A) insert()
B) append()
C) extend()
D) add()
Answer: B) append()
Rationale: append() adds a single element to the end of a list. insert() adds at a
specific index, extend() adds multiple elements from another iterable, and add() is
not a list method (it's for sets).


Question 5

,What does the pass statement do in Python?
A) Terminates the program
B) Does nothing and acts as a placeholder
C) Skips the next iteration of a loop
D) Exits a function
Answer: B) Does nothing and acts as a placeholder
Rationale: pass is a null operation - it does nothing when executed. It's used as a
placeholder where syntax requires a statement but you don't want any action to be
taken, such as in empty function or class definitions.


Question 6
What is the output?
python
s = "Hello World"
print(s[6:])
A) "World"
B) "World "
C) "World"
D) "llo World"
Answer: A) "World"
Rationale: String slicing [start:end] extracts characters from index start to end-1.
Index 6 is 'W' (H=0, e=1, l=2, l=3, o=4, space=5, W=6), and since no end is
specified, it goes to the end of the string.


Question 7
Which operator is used for string concatenation?
A) &
B) .

,C) +
D) *
Answer: C) +
Rationale: In Python, the + operator concatenates strings. Example: "Hello" + " "
+ "World" results in "Hello World". * is used for repetition, not concatenation.


Question 8
What is the correct way to create a tuple?
A) my_tuple = [1, 2, 3]
B) my_tuple = (1, 2, 3)
C) my_tuple = {1, 2, 3}
D) my_tuple = <1, 2, 3>
Answer: B) my_tuple = (1, 2, 3)
Rationale: Tuples are created using parentheses (). Lists use square brackets [],
sets use curly braces {}, and angle brackets <> are not used for Python data
structures.


Question 9
What is the output of the following?
python
print(2 ** 3 ** 2)
A) 64
B) 512
C) 729
D) 128
Answer: B) 512
Rationale: The exponentiation operator ** has right-to-left associativity. So 2 ** 3
** 2 is evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512.

Document information

Uploaded on
November 21, 2026
Number of pages
95
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$21.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

Sold
3
Followers
0
Items
142
Last sold
3 weeks 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