subject

In this homework you will design a class dog and save it in a file named dog. py. (important hint: when you change the file dog. py the changes will not be reflected in an old shell, even if you import dog again. start a new shell to test your changes.)

problem 1. write a class definition line and a one line docstring for the class dog. write an __init__ method for the class dog that gives each dog its own name and breed. make sure that you test this on a successful creation of a dog object. for example,

> > > import dog
> > > sugar = dog. dog('sugar', 'border collie')
> > > sugar. name
sugar
> > > sugar. breed
border collie

problem 2. add a list attribute tricks to each dog and initialize it in __init__ to the empty list. (the user does not have to supply a list of tricks when creating a dog.) make sure that you test this successfully.

> > > sugar. tricks
[]

problem 3. write a method teach as part of the class dog. the method teach should add a passed string parameter to tricks and print a message that the dog that knows the trick.

> > > sugar. teach('frisbee')
sugar knows frisbee

problem 4. write a method knows as part of the class dog. the method knows should check whether a passed string parameter is in the dog’s list of tricks, print an appropriate message and return true or false.

> > > sugar. knows('frisbee')
yes, sugar knows frisbee
true
> > > sugar. knows('arithmetic')
no, sugar doesn't know arithmetic
false

problem 5. create a data attribute species as part of the class dog and set its value to 'canis familiaris'. the method species should be defined within the class dog but outside of any method.

> > > dog. dog. species
'canis familiaris'
> > > sugar. species
'canis familiaris'

plese explain your code for each problem, line by line if possible

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 12:00
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
Answers: 1
question
Computers and Technology, 24.06.2019 12:10
What is it called during the editing process when the processor ensures that a character holding a coffee mug from one angle is holding the same mug in the same way when the shot switches to another camera at another angle? cinematography continuity technology prop use
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
Which of the following best describe how the depth-limited search works. a normal depth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but values above a specific value will be ignored. a normal depth-first search is performed but values above a specific value will be ignored.
Answers: 1
You know the right answer?
In this homework you will design a class dog and save it in a file named dog. py. (important hint:...
Questions
question
Mathematics, 04.06.2021 14:00
question
Mathematics, 04.06.2021 14:00
question
Mathematics, 04.06.2021 14:00
question
Mathematics, 04.06.2021 14:00
question
Physics, 04.06.2021 14:00
Questions on the website: 13722363