Question: The following pertains to python programming. Will upvote, thank you. 1) Complete a class, petClass(), which was used in the lecture video. Add a function

The following pertains to python programming. Will upvote, thank you.

1) Complete a class, petClass(), which was used in the lecture video.

  • Add a function changeName() that will change the name of the pet.

  • Add another function nickName() that will assign a nick to the pet. You need to add another class member variable, nick, to make the testing script to work properly.

a) # Complete the following class. DO NOT CHANGE THE CLASS NAME!

class petClass(): def __init__(self, name, color="brown" ): self.name = name self.color = color def petColor(self): print(self.name, 'is', self.color) def dye(self, color): self.color = color self.petColor() def changeName 

-------

# The following code is provided for your test, You can modify it as you want, to test your function. myDog = petClass('Spot', 'black and white') print(myDog.name) print(" ") myDog.changeName('Cow') print(myDog.name) print(" ") print(myDog.nick) myDog.nickName('Ticky') print(myDog.nick) print(" ")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!