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

WGU D522 Python for IT Automation

Document preview thumbnail
Preview 4 out of 48 pages

WGU D522 Python for IT Automation

Content preview

WGU D522 Python for IT Automation - 200
Exam Questions & Answers (2026/2027)
Version 1: Python Fundamentals & Data
Structures
Section 1: Python Basics & Syntax
(Questions 1-25)
Q1: What is the primary use of whitespace in Python?
A) To improve code readability only
B) To define the structure and hierarchy of the code
C) To separate variables
D) To indicate comments
Answer: B
Rationale: In Python, whitespace (indentation) is syntactically significant and
defines code blocks, unlike many other languages that use curly braces or
keywords. This is a fundamental Python concept .
Q2: Which of the following is NOT a valid Python variable name?
A) my_var
B) _internal
C) 2nd_attempt
D) userName
Answer: C
Rationale: Python variable names cannot start with a number. They must start with
a letter or underscore and can only contain letters, numbers, and underscores .
Q3: What does the input() function return in Python?
A) An integer
B) A float
C) A string
D) A boolean

,Answer: C
Rationale: The input() function always returns user input as a string, regardless of
what the user types. Type conversion must be performed separately .
Q4: Which error occurs when a program tries to use a variable that does not
exist?
A) Syntax Error
B) ValueError
C) NameError
D) TypeError
Answer: C
Rationale: A NameError is raised when Python encounters a variable name that
hasn't been defined in the current scope .
Q5: What is the purpose of indentation in Python?
A) To make code look professional
B) To define blocks of code
C) To separate statements
D) To indicate comments
Answer: B
Rationale: Indentation is how Python defines scope for control flow statements,
functions, and classes. Inconsistent indentation causes IndentationError .
Q6: Which Python data type represents an ordered, mutable sequence?
A) Tuple
B) Set
C) List
D) Dictionary
Answer: C
Rationale: Lists are ordered, mutable collections that allow indexing, slicing, and
modification. This makes them ideal for storing sequences that need to change .
Q7: What happens when an operation involves both an int and a float in
Python?
A) An error occurs
B) The result is automatically promoted to float
C) The result is truncated to int

,D) The operation is ignored
Answer: B
Rationale: Python automatically promotes integers to floats when performing
operations with floating-point numbers to preserve precision .
Q8: Which escape character creates a new line in a string?
A) \t
B) \n
C) \r
D) \b
Answer: B
Rationale: The \n escape sequence inserts a newline character in a string .
Q9: What is the result of print("Hello" + 5) in Python?
A) Hello5
B) 5Hello
C) TypeError
D) Hello 5
Answer: C
Rationale: The + operator cannot concatenate a string and an integer. This raises
a TypeError, requiring explicit type conversion .
Q10: Which method removes leading and trailing whitespace from a string?
A) trim()
B) strip()
C) remove()
D) clean()
Answer: B
Rationale: The strip() method removes leading and trailing whitespace
characters. lstrip() and rstrip() remove from left or right only .
Q11: What does the len() function return when used on a list?
A) The number of characters in the list representation
B) The number of elements in the list
C) The memory size of the list
D) The last index of the list
Answer: B

,Rationale: len() returns the total number of elements in an iterable, including lists,
tuples, strings, and dictionaries .
Q12: What are the three components of a string slice?
A) [start:end:count]
B) [start:stop:step]
C) [begin:finish:increment]
D) [first:last:skip]
Answer: B
Rationale: String slicing uses [start:stop:step] where start is inclusive, stop is
exclusive, and step is optional .
Q13: What does the // operator do in Python?
A) Performs regular division
B) Performs floor division
C) Performs modulo operation
D) Performs exponentiation
Answer: B
Rationale: The // operator performs floor division, rounding down to the nearest
whole number and discarding the decimal part .
Q14: Which of the following are truthy values in Python?
A) 0, None, ""
B) 1, "Hello", [1,2]
C) False, 0, []
D) None, False, 0
Answer: B
Rationale: Truthy values include non-zero numbers and non-empty collections.
Falsy values include zero, None, and empty collections .
Q15: How do you check the version of Python you are using?
A) python --version
B) import sys; print(sys.version)
C) version()
D) import os; print(os.version)
Answer: B

Document information

Uploaded on
November 21, 2026
Number of pages
48
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$23.49

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