OOP – Class Variables vs Instance Variables
A class variable is shared across all instances; an instance variable is unique to each object
What it does: Class variables are defined directly in the class body, outside any method. self.name stores data that belongs to one specific object. Instance variables use self — they're created in __init__ and belong to each object. count is defined on the class itself, so all Dog instances share the same count. self.name is unique to each dog; Dog.species is one value shared by all dogs. Modifying Dog.count changes it for every instance — it's the class-level value. Class variables suit things like instance counters or constants shared by all objects. Assigning self.species = 'Feline' creates an instance variable hiding the class one for that dog only.
Common mistakes: count should be a class variable, not instance. Define at class level. Redundant species is already a class variable. No need to set in __init__.
Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
Class variableFill in the Blanks
Spot the Error
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →