Lesson 32 of 34
Methods: What Objects Can Do
10 min 35 XP
Functions written inside a class are called methods. Their first parameter is always self. A method can read and change the object's data.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.With a __str__ method, print(object) shows friendly text.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.