Pass the WGU D335 Python Objective Assessment with Confidence — 350+ Practice Questions and Detailed Code Explanations.
This comprehensive study guide is designed specifically for Western Governors University (WGU) students enrolled in D335: Introduction to Programming in Python. With over 350 realistic exam-style questions, each followed by a clear, detailed rationale, this guide helps you master Python fundamentals and pass your Objective Assessment (OA) on the first attempt.
What’s Inside:
350+ WGU D335-style questions covering every major exam competency
Detailed answer explanations for every question — not just what's correct, but why
Python Fundamentals: Variables, data types, operators, type conversion, input/output, and comments
Strings & String Methods: Indexing, slicing, .upper(), .lower(), .strip(), .split(), .replace(), .find(), and more
Lists, Tuples & Sets: Append, insert, remove, pop, sort, reverse, set operations (union, intersection, difference), and comprehensions
Dictionaries: Key-value access, .get(), .keys(), .values(), .items(), .update(), and dictionary comprehensions
Control Flow: if, elif, else, nested conditionals, ternary operators, and comparison operators
Loops: for loops, while loops, range(), break, continue, pass, and loop else clauses
Functions: def, parameters, return values, default arguments, *args, **kwargs, lambda functions, recursion, and scope
File I/O & Modules: open(), read(), write(), readlines(), with statements, import, and standard libraries (math, random, json, csv, datetime, re)
Exception Handling: try, except, finally, raise, and common exception types (ValueError, TypeError, ZeroDivisionError)
Advanced Topics: pickle, decimal, collections (Counter, defaultdict, OrderedDict), itertools (count, cycle, repeat), and functools (reduce, lru_cache)
Perfect for:
WGU D335 students preparing for the Objective Assessment (OA)
Beginner Python programmers seeking certification
Anyone needing a comprehensive Python fundamentals refresher
Coding bootcamp students and self-taught programmers
Why Choose This Guide?
Most study guides only give you questions. This one teaches you the Python logic behind every answer. Whether you are preparing for your WGU OA or building a solid Python foundation, this book provides the edge you need to succeed.
Content preview
WGU D335 INTRODUCTION TO PROGRAMMING
IN PYTHON — COMPREHENSIVE PRACTICE
EXAM (350 QUESTIONS) AND DETAILED
SOLUTIONS
Section 1: Python Basics, Syntax, and Variables (Questions 1–40)
1. Which of the following is the correct way to output text to the console in
Python?
A. echo "Hello, World!"
B. print("Hello, World!")
C. console.log("Hello, World!")
D. printf("Hello, World!")
Correct Answer: B
Rationale: The built-in `print()` function is the standard way to display output in
Python. `echo` is a shell command, `console.log` is JavaScript, and `printf` is
C/C++.
2. What symbol begins a single-line comment in Python?
A. `//`
,B. `/*`
C. `#`
D. `--`
Correct Answer: C
Rationale: Python uses the `#` symbol for single-line comments. `//` is used for
floor division, `/* */` is for block comments in C-style languages, and `--` is used in
SQL and some other languages.
3. Which of the following variable names is invalid in Python?
A. `_my_var`
B. `myVar2`
C. `2myVar`
D. `MY_VAR`
Correct Answer: C
Rationale: Variable names cannot begin with a digit. They may begin with a letter
or an underscore. Options A, B, and D all follow valid naming conventions.
4. What data type does the expression `3 + 4.0` produce?
A. `int`
,B. `float`
C. `str`
D. `complex`
Correct Answer: B
Rationale: Python automatically promotes the integer `3` to a float (`3.0`) when
mixing types. The result is `7.0`, which is a `float`.
5. Which built-in function converts a value to a string?
A. `int()`
B. `float()`
C. `str()`
D. `string()`
Correct Answer: C
Rationale: `str()` converts any value to its string representation. `int()` and `float()`
convert to numeric types. `string()` is not a built-in function.
6. What is the output of the following code?
```python
x=5
, y=2
print(x // y)
```
A. 2.5
B. 2
C. 3
D. 1
Correct Answer: B
Rationale: The `//` operator performs floor division. `5 // 2` equals `2` because it
discards the fractional part.
7. What is the output of `print(7 % 3)`?
A. 2.33
B. 2
C. 1
D. 0
Correct Answer: C
Rationale: The modulo operator `%` returns the remainder. `7` divided by `3`
leaves a remainder of `1`.