By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Study Guide: Python – Object-Oriented Programming Basics (Grade 8, Computer Science/ICT)
"If you’re building a video game where every enemy, player, and power-up has its own rules, how do you keep the code from turning into a giant, tangled mess? Why can’t you just write one long list of instructions like you did for simple scripts—and what’s the better way?"
Imagine you’re designing a robot soccer team in Python. Each robot has: - Attributes (speed, battery level, jersey color) - Behaviors (kick(), dodge(), recharge())
If you wrote separate code for every robot, you’d repeat the same logic over and over. Instead, you create a blueprint (a class) called Robot that defines what all robots can do. Then, you make instances of that blueprint—like player1 = Robot("red", 5)—to customize each robot without rewriting the rules. This is object-oriented programming (OOP): organizing code into reusable "objects" that bundle data and actions together, just like real-world things.
Robot
player1 = Robot("red", 5)
Key Vocabulary:- Class Definition: A blueprint for creating objects that defines their attributes and behaviors. Example: A Dog class might include breed, age, and methods like bark() or fetch()—but it’s not a specific dog yet. Note: In college, classes become more abstract (e.g., metaclasses, inheritance hierarchies).
Dog
breed
age
bark()
fetch()
Object (Instance) Definition: A specific "thing" created from a class, with its own unique data. Example: my_dog = Dog("Golden Retriever", 3) is an instance of the Dog class—it’s the actual dog named "Buddy" in your code.
my_dog = Dog("Golden Retriever", 3)
Method Definition: A function defined inside a class that describes what an object can do. Example: In a Car class, accelerate() might increase the car’s speed by 10 mph each time it’s called.
Car
accelerate()
Attribute Definition: A variable stored inside an object that describes its state (like properties or traits). Example: A Student object might have attributes name = "Jamie" and grade = 8.
Student
name = "Jamie"
grade = 8
How This Appears on Assessments:- Classroom Formative: Short coding tasks (e.g., "Write a Book class with title, author, and a describe() method").- State Standardized Tests (e.g., CSTA, state ICT exams): Multiple-choice questions about OOP concepts (e.g., "Which line creates an instance of a Cat class?") or debugging snippets of code.- Performance Tasks: Build a small program (e.g., a BankAccount class with deposit() and withdraw() methods) and explain your design.
Book
title
author
describe()
Cat
BankAccount
deposit()
withdraw()
Distractor Patterns in Multiple Choice:- Confusing class with instance (e.g., "A class is a specific object" vs. "A class is a template").- Misidentifying methods vs. attributes (e.g., color is an attribute; paint() is a method).- Forgetting self in method definitions (e.g., def bark(): instead of def bark(self):).
color
paint()
self
def bark():
def bark(self):
Model Proficient Response (Short Constructed Response):Prompt: "Explain why using a Player class is better than writing separate code for each player in a game. Give an example."
Player
Response: "Using a Player class is better because it lets you define the rules once and reuse them for every player. For example, if you write a Player class with attributes like health and score, and methods like take_damage(), you can create 100 players without rewriting the same code. If you need to change how damage works, you only update the class, not every player’s code. Without a class, you’d have to copy-paste the same logic for each player, which is messy and error-prone."
health
score
take_damage()
Mistake 1: Forgetting self in MethodsPrompt: Write a Rectangle class with a method area() that calculates the area.Common Wrong Response:
Rectangle
area()
class Rectangle: def __init__(self, width, height): width = width height = height def area(): return width * height
Why It Loses Credit: - area() is missing self, so Python can’t access the object’s attributes.- width and height in __init__ aren’t saved as attributes (no self.width).Correct Approach:
width
height
__init__
self.width
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def area(self): return self.width * self.height
Mistake 2: Confusing Class and InstancePrompt: "What does this code print? Explain."
class Dog: species = "Canine" def __init__(self, name): self.name = name fido = Dog("Fido") print(fido.species)
Common Wrong Response: "It prints name because fido is an instance." Why It Loses Credit: - Misunderstands that species is a class attribute (shared by all dogs), while name is an instance attribute.Correct Approach: "It prints Canine because species is defined for the whole Dog class, not just fido. All dogs share this attribute unless it’s overridden."
name
fido
species
Canine
Mistake 3: Overcomplicating InheritancePrompt: "Write a Bird class and a Penguin class that inherits from it. Penguins can’t fly." Common Wrong Response:
Bird
Penguin
class Bird: def fly(self): print("Flying!") class Penguin(Bird): def fly(self): print("I can't fly!") def swim(self): print("Swimming!")
Why It Loses Credit: - The student overrides fly() but doesn’t explain why inheritance is useful here (e.g., all birds share some traits, but penguins modify one).Correct Approach:
fly()
class Bird: def __init__(self, name): self.name = name def fly(self): print(f"{self.name} is flying!") class Penguin(Bird): def fly(self): print(f"{self.name} can't fly, but can swim!")
Explanation: "Penguin inherits from Bird to reuse name and other bird traits, but overrides fly() to customize it. This avoids rewriting code for every bird type."
Within Computer Science: OOP → Data Structures — Understanding classes helps you grasp how Python’s built-in types (like list or dict) are actually objects with methods (e.g., my_list.append()).
list
dict
my_list.append()
Across Subjects: OOP → Biology — Classes are like species: a Lion class defines traits all lions share, while simba = Lion() is an instance (a specific lion). Inheritance is like evolution (e.g., Penguin inherits from Bird but adapts).
Lion
simba = Lion()
Outside School: OOP → Lego Sets — A Lego instruction booklet is like a class: it tells you how to build a car (attributes: wheels, color; methods: "drive"). The actual car you build is an instance. If you modify it (e.g., add a spoiler), that’s like overriding a method.
"If you can write any program without OOP (just using functions and variables), why do programmers bother with classes at all? What’s the real advantage—beyond just ‘it’s neater’?"
Pointer Toward the Answer: OOP’s power isn’t just organization—it’s about modeling relationships. For example, in a game, a Sword class might have a damage attribute, but a Player class could own a sword (e.g., self.weapon = Sword(10)). This lets you write code like player.attack(), where the player’s attack delegates to their weapon’s damage. Without OOP, you’d have to manually track every sword’s damage separately, which gets chaotic as the game grows. The real advantage is scalability: OOP lets you build systems where objects interact without knowing the details of each other’s code. (Think of how a light switch "knows" how to turn on a bulb, but doesn’t need to know how the bulb works internally.)
Sword
damage
self.weapon = Sword(10)
player.attack()
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.