Question: Solve in Python Please. Lab 1 2 B: My dog can do tricks For this lab we are going to create a Dog class. Dog

Solve in Python Please.
Lab12B: My dog can do tricks
For this lab we are going to create a Dog class.
Dog objects have a few attributes, but this time unlike chair objects they can also do some cool things
too. Each action is represented by a method. Therefore, for any action our Dog can do or we do to the
Dog, we are going to create a method. For example, if you want my Dog to bark, you can create a
method to do that in the Dog class and call that method outside of the class (once you have created
an object).
Dog class:
Variables (Attributes):
Behaviors (Methods):
bark
rename
eat
# prints "Woof! Woof!"
# take a string and change the name of the dog
# take a float and add that number to weight
Keep in mind that methods inside of a class will always take the "self" parameter. This parameter is
always automatically passed whenever you call a method from an object. However, some methods
must take in more than just the "self" parameter; in this case, these extra parameters must be passed
before the method can be called.
Outside the Dog class, create a new Dog object and prompt the user to input the attributes describing
this Dog. Once done, print out all the details about the Dog, as per the sample output.
Next, use the methods you created in the Dog class to have it bark, change the name (using the
rename method, not the dot operator), and feed it.
Finally print out all the details about the Dog, the object should have changed because of your calls to
the various methods.
Sample output (user input in bold):
You are about to create a dog.
How old is the dog: 5
How much does the dog weigh: 30.5
What is the dogs name: Patches
What color is the dog: chocolate
What breed is the dog: lab
Patches is a 5 year old chocolate lab that weighs 30.5 lbs.
Woof! Woof!
Patches is hungry, how much should he eat: 5000.3
Patches isnt a very good name. What should they be renamed to: Sparky
Sparky is a 5 year old chocolate lab that weighs 5030.8 lbs.
Solve in Python Please. Lab 1 2 B: My dog can do

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 Programming Questions!