OOP Blocks

Module 1 · Classes & Objects · A-Level · Python
💡 What's the big idea? (read me first)

A class is a blueprint. An object is a thing built from that blueprint. One Dog class can make many dog objects — each with its own state. That single idea is the heart of OOP, and it's why this app has an Object Bench on the right: every object you create appears there as its own card.

attributeA piece of data an object stores (e.g. name, age).
accessprivate (🔒) = only the object's own methods can touch it — the safe default. public (🔓) = anything can read/change it directly with obj.attr, no protection.
constructorThe special method that runs when you build an object. In Python it's __init__ — it takes the attributes as parameters and sets them up.
getterA method that reads a private attribute: get_age(). The safe way to look inside.
setterA method that changes a private attribute: set_age(4).
new objectBuilding an object by calling the constructor: d1 = Dog("Rex", 3). This is instantiation.

Encapsulation: make an attribute private and the only way in is its getter/setter — try to change it without a setter and you get an error. Make it public and you can change it directly with obj.attr, with no protection. That trade-off is the whole point.

🧩 Blocks

🏗️ Blueprint — the class drag attributes / getters / setters here

class :
▶ Program — create & use objects

🐍 Equivalent Python updates as you build

🪑 Object Bench live objects & their state

No objects yet. Build a class, add a Create object block, then press ▶ Run.

🖥️ Output

—

🎯 Tasks (PRIMM)

OOP Blocks · Module 1 of the OOP_Blocks series · self-contained, no server. Private attributes use Python's self.__attr name-mangling convention.