IN PYTHON OBJECTIVE ASSESSMENT 2026 |
PRACTICE QUESTIONS WITH VERIFIED
ANSWERS & DETAILED RATIONALES | LATEST
VERSION
WGU D335 — INTRODUCTION TO PROGRAMMING IN PYTHON
OBJECTIVE ASSESSMENT
PRACTICE QUESTIONS WITH VERIFIED ANSWERS & DETAILED RATIONALE |
LATEST VERSION
400 Multiple Choice Questions
SECTION 1: PYTHON FUNDAMENTALS
Q1. What is Python primarily classified as?
A) A compiled, statically typed language B) A markup language C) A low-level
machine language D) An interpreted, high-level, general-purpose
programming language E) A hardware description language
✔ CORRECT ANSWER: D RATIONALE: Python is an interpreted language,
meaning code is executed line by line by the Python interpreter. It is high-level because
it abstracts away memory management and hardware details, and general-purpose
because it supports web development, data science, automation, AI, and more.
Q2. Which symbol is used to write a single-line comment in Python?
A) // B) /* */ C) # D) -- E) $$
✔ CORRECT ANSWER: C RATIONALE: In Python, the hash symbol # begins a
single-line comment. Everything after # on that line is ignored by the interpreter. // is
used in languages like JavaScript and C++.
Q3. What will print(type(5)) output?
, A) <class 'float'> B) <class 'str'> C) <class 'int'> D) <class 'number'> E)
<class 'double'>
✔ CORRECT ANSWER: C RATIONALE: The integer literal 5 belongs to the int
class in Python. type() returns the data type of a value, and Python uses <class 'int'> as
its representation for integers.
Q4. Which of the following is a valid Python variable name?
A) 2variable B) my-variable C) class D) my_variable E) my variable
✔ CORRECT ANSWER: D RATIONALE: Python variable names must begin with
a letter or underscore, followed by letters, digits, or underscores. 2variable starts with a
digit, my-variable contains a hyphen, class is a reserved keyword, and my variable
contains a space.
Q5. What does the print() function do in Python?
A) Reads input from the user B) Saves data to a file C) Outputs text or
values to the console D) Declares a variable E) Compiles the program
✔ CORRECT ANSWER: C RATIONALE: The print() function outputs its
arguments to standard output (the console). It is one of Python's built-in functions and is
commonly used for displaying results, debugging, and user interaction.
Q6. Which of the following correctly assigns the value 10 to a variable named x?
A) x == 10 B) 10 = x C) x = 10 D) int x = 10 E) var x = 10
✔ CORRECT ANSWER: C RATIONALE: In Python, the single = is the
assignment operator. The variable name goes on the left and the value on the right. ==
is for comparison, and Python does not require type declarations like int.
Q7. What is the output of print() in Python 3?
A) 3 B) 3.0 C) 3.3333333333333335 D) 3.33 E) Error
,✔ CORRECT ANSWER: C RATIONALE: In Python 3, the / operator always
performs true (float) division, returning a float. The result is 3.3333333333333335 due to
floating-point representation. To get integer division, use //.
Q8. What operator is used for integer (floor) division in Python?
A) / B) % C) // D) div E) \
✔ CORRECT ANSWER: C RATIONALE: The // operator performs floor division,
discarding the decimal part and returning an integer result. For example, 10 // 3 returns
3. The % operator returns the remainder (modulus).
Q9. What does the modulus operator % return?
A) The quotient of division B) The remainder of division C) The power of a
number D) The square root E) The floor of division
✔ CORRECT ANSWER: B RATIONALE: The % operator returns the remainder
after dividing one number by another. For example, 10 % 3 returns 1 because 10
divided by 3 is 3 with a remainder of 1. It is commonly used to check even/odd
numbers.
Q10. What is the output of print(2 ** 4)?
A) 6 B) 8 C) 16 D) 24 E) 2
✔ CORRECT ANSWER: C RATIONALE: The ** operator is the exponentiation
(power) operator in Python. 2 ** 4 means 2 raised to the power of 4, which is 2×2×2×2 =
16.
Q11. Which function is used to accept user input in Python?
A) read() B) scan() C) get() D) input() E) fetch()
✔ CORRECT ANSWER: D RATIONALE: input() reads a line of text from the user
via the console and returns it as a string. For example, name = input("Enter your name:
") prompts the user and stores their response.
, Q12. What data type does input() always return?
A) int B) float C) str D) bool E) list
✔ CORRECT ANSWER: C RATIONALE: Regardless of what the user types,
input() always returns the value as a string (str). If a numeric value is needed, you must
convert it explicitly using int() or float().
Q13. How do you convert the string "42" to an integer?
A) str(42) B) int("42") C) float("42") D) convert("42") E) parse("42")
✔ CORRECT ANSWER: B RATIONALE: The int() function converts a compatible
string or float to an integer. int("42") returns the integer 42. float("42") would return 42.0,
and str(42) converts an integer back to string.
Q14. Which of the following is NOT a built-in Python data type?
A) int B) str C) bool D) char E) float
✔ CORRECT ANSWER: D RATIONALE: Python does not have a char data type
(unlike C or Java). Individual characters are simply strings of length 1. Python's built-in
types include int, float, str, bool, list, tuple, set, and dict.
Q15. What is the Boolean value of an empty string "" in Python?
A) True B) False C) None D) 0 E) Error
✔ CORRECT ANSWER: B RATIONALE: In Python, empty containers and zero-
like values evaluate to False. An empty string "", empty list [], 0, 0.0, and None are all
considered falsy. Any non-empty string or non-zero number is truthy.
Q16. What is the correct way to write a multi-line string in Python?
A) Using single quotes '...' B) Using double quotes "..." C) Using triple
quotes """...""" or '''...''' D) Using backslashes at each line end E) Using \n
characters only