190k views
3 votes
in the kangaroo class, complete the function definition for setcolor() that takes in the string parameter newcolor.

User KanisXXX
by
8.2k points

1 Answer

3 votes

Answer:

implementation of the
setcolor() function in the Kangaroo class, which takes a string parameter newcolor and sets the kangaroo's color to that value:

class Kangaroo:

def __init__(self, name, age, color):

self.name = name

self.age = age

self.color = color

def setcolor(self, newcolor):

self.color = newcolor

Step-by-step explanation:

In this implementation, setcolor() simply sets the color attribute of the Kangaroo object to the value of newcolor.

User Scolfax
by
8.0k points