Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started