E066
Object Oriented Programming in
Python
Classes, composition, traversal, and reliable code
20 WHY APPLY
original questions explained solutions worked examples
Independent course-topic review. Original learning material.
Not affiliated with or endorsed by Western Governors University.
EDITION 1.0 | 29 OCTOBER 2026
,ACCELERATED REVIEWS E066 / INDEPENDENT STUDY GUIDE
Contents
Module 1 - Classes, objects, state, and methods 3
Module 2 - Encapsulation, properties, and invariants 4
Module 3 - Inheritance, overriding, and super() 5
Module 4 - Composition and choosing an object boundary 6
Module 5 - Polymorphism and abstraction 6
Module 6 - Validation, exceptions, and reliable tests 7
Module 7 - Hierarchies, recursive and iterative traversal, maintenance 8
Compact reference 10
Practice: 20 original questions and exercises 10
Explained solutions 11
Three-session study plan 12
Glossary: 12 terms 13
Primary sources 14
Edition 1.0 - October 2026 2
,ACCELERATED REVIEWS E066 / INDEPENDENT STUDY GUIDE
Object oriented programming (OOP) organizes related data and behavior into objects. The point is to make state
changes predictable and code easier to extend, inspect, and test. This review uses small, original device, lending,
and library examples. Run each block with Python 3.11 or newer, predict its output before reading the explanation,
then change one input and predict again.
Scope. This is an independent topic review based on the publicly described E066 scope. It is not official course
material, exhaustive exam alignment, an assessment replica, or a pass guarantee.
Module 1 - Classes, objects, state, and methods
A class defines a type; an object is an instance of that type. An object's attributes hold its state, and methods
express valid operations. __init__ establishes a usable starting state. An instance method receives the instance
as self, so two objects can use the same method code while keeping separate state. Class attributes belong to
the class and are shared by lookup; instance attributes belong to each object. Use a class attribute for a stable
category or constant, not for a mutable list intended to belong to each instance.
Here a counter represents one device. The class attribute identifies the kind of device; each counter owns its own
reading. A method changes the reading and returns the new value, which gives callers a simple contract. The if
__name__ guard makes the block runnable while keeping the demo out of imports.
class PulseCounter:
unit = "pulses"
def __init__(self, label: str) -> None:
self.label = label
self.count = 0
def record(self, amount: int = 1) -> int:
self.count += amount
return self.count
if __name__ == "__main__":
left = PulseCounter("left")
right = PulseCounter("right")
assert left.record(2) == 2
assert right.count == 0
assert left.unit == right.unit == "pulses"
print(left.label, left.count, right.count)
The output is left 2 0. left.count and right.count are independent because __init__ assigned each instance
its own value. unit is found through the class when accessed on either object. A production record method would
validate amount; module 6 adds that boundary.
Common error. Writing readings = [] in the class body and appending per-device readings to it makes every
instance see the same list. Move the assignment to self.readings = [] inside __init__.
Retrieval prompt. Without looking back, sketch the attributes created by two instances after left.record(2).
Which name is shared, and which values are stored separately?
Edition 1.0 - October 2026 3