class Cat:
“““ A Sample Program to Model a Cat.”””
def __int__(data, name, age):
“”” Let us initialize the age and name attributes of the Cat.”””
data.name = name
data.age = age
def spit(data):
“““ Stimulate the Cat to spit saliva.”””
print(f “{data.name} is spitting saliva.”””
def (sit):
“““ Make the Cat to sit.”””
print(f “{data.name} is sitting on the floor.”
There are many things you will notice in this program, but don’t worry
because, at the end of this chapter, you will be familiar with this structure.
The first line of code is a class definition called Cat. The second line is a
docstring, which describes the role of the class.
Do'stlaringiz bilan baham: