Methods are functions within the class which will act on attributes of the class. The simplest implementation just looks like a function. I add the method under the __init__ code block at the same indentation as the __init__ method.
I can then call this method by the following line at the end of my code.
my_object.my_method2(“Slartibartfast”)
As demonstrated with functions in previous notes, I can set a default value for an argument.
Exercise
Create and document a template for your own use, such that whenever you need a simple class, you can just copy the source code. Call it class_template.py.