Learn how one class can create many useful objects in your programs.
A class is a blueprint for making objects. An object is one usable thing made from that blueprint. You can use this idea to model students, bank accounts, game characters, or anything with data and actions.
The class describes what an object has and can do. Its attributes store information, such as a name or score. Its methods describe actions, such as jumping or adding points.
This class describes a dog. The constructor runs when a new dog is created. It stores the dog's name, and the bark method gives the object an action.
Now the Dog class creates two separate objects. Both have the same structure and method, but each stores a different name. Calling bark on each object uses that object's own data.
Notice the two objects behave through the same method, but their results differ because their name attributes differ. This is a key benefit of classes: write the behavior once, then reuse it for many objects.
A class is not the same as an object. Dog is the blueprint, while luna is one object made from it. Also, use self.name for each object's data. A shared name variable would make the dogs lose their separate identities.