Constructor

Domain: Programming Fundamentals

🎯 Motivation

When creating an object, you need to set up its initial data. The constructor is the method that runs on creation.

📋 Concrete Example

def __init__(self, name): self.name = name - when you call Dog('Rex'), this method runs automatically and sets name to Rex.

🔗 Analogy

The setup crew for a new restaurant - before opening day, they stock the kitchen, set the tables, and train the staff. The restaurant is ready to operate.