Professional Documents
Culture Documents
Previously we created get methods to retrieve information about our objects. What if we
want to set/change information? For this we use set methods that allow us to change
information within our objects.
An example set method has been created in the Pet object below:
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
self.description = description
Modify your pets.py class file to include the set_name() method above and check it
works by calling it in your my_pets.py file.
Add two additional methods to your Pet object that allow you to set the species and
description.
Resources are updated regularly — the latest version is available at: ncce.io/tcc.
This resource is licensed under the Open Government Licence, version 3. For more information on this
licence, see ncce.io/ogl.