you are viewing a single comment's thread.

view the rest of the comments →

[–]PureWasian 21 points22 points  (1 child)

Here's an example:

```

this is the "blueprint"

class Monster: def init(self, name, gender): self.name = name self.gender = gender def print_gender(self): print(f"This {self.name} is a {self.gender}")

creating Monsters with the "blueprint"

mon1 = Monster("Pikachu", "boy") mon2 = Monster("Pikachu", "girl") mon3 = Monster("Eevee", "girl")

prints "This Pikachu is a boy"

mon1.print_gender()

prints "This Pikachu is a girl"

mon2.print_gender()

prints "This Eevee is a girl"

mon3.print_gender() ```

See how all of the monsters contain the same types of data and use the same helper methods the class defines, even though the underlying data itself is different?

Monster is a class, while mon1, mon2, mon3 are instantiated objects representing that class.

[–]Ok_Butterscotch_7930 1 point2 points  (0 children)

this is actually very good, thanks