class Dog:
species = 'Canis familiaris' # data attribute species
def __init__(self, name, breed): # initialize name and tricks for each dog
self.name = name
self.breed = breed
self.tricks = []
def teach(self, trick):
self.tricks.append(trick) # add passed trick to tricks list
print(self.name, 'knows', trick) # print message
def knows(self, trick):
if trick in self.tricks: # If passed trick exists in list, print that dog knows trick else not
print('Yes,', self.name, 'knows', trick)
return True
else:
print('No', self.name, 'doesn\'t know', trick)
return False
SCREENSHOT

OUTPUT

Python vUniess you need to edit, it's safer to stay in Enable Editing Propiem 1 Write...
ws. Unless you need to edit it's safer to stay in Protected View Enable Editing Alternation of generations describes plant life cycles. There are ſhow many?) generations. • The gametophyte generation begins when the process of forms (ploidy) cells. The gametophyte generation ends when a (ploidy) _ is formed by the process of_ Figure 38.4 Alternation of generations: What are the two generations in the plant life cycle? What is the male gametophyte? Female? The microsporangium in the pollen sac....
you need to edit, it's safer to stay in Protected View. Enable Editing Part 2- Time to Dig Deeper - Doin' Your Research 1. Remember critical thinking is about exposing yourself to OTHER thinking and evaluating it. Now you will RESEARCH the topic. For this you need to find 2 FACTS that support the ban and 2 FACTS that oppose the ban (you can have more but you must have a MINIMUM of two for each). You will not only...
ses. Unless you need to edit, it's safer to stay in Protected View Enable Editing activate now. Reactivate 1. Given an angle of 18°15'02', convert the angle to degrees with decimal rounded to the nearest 0.001" (4 pts.) 2. Given an angle of 48.871", convert the angle to degrees, minutes, and seconds (DMS). Round to the nearest second. (4 pts.) 3. A downhill slope measures 402.22' from point to point D. Both points are on the ground. The elevation at...
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
I need help asap, Python language
2) Write a class to represent a class to represent a Car and its passengers. Write a constructor that takes one additional parameter a number, the total seats in the car. The constructor should save this as a datamember and also initialize an additional datamember, a list, to keep track of the passengers in the car. Write method addRider that takes an additional parameter a string of the passenger to be added to the...
%%%%Python Question%%% Work from the template acrostic.py, which you can find on the ELMS page for this assignment. • In the Generator class, write an __init__() method with two parameters: self and the path to a text file containing one word per line. This method should read the words from the file, strip off leading and trailing whitespace, and store them in a dictionary where each key is a lower-case letter and each corresponding value is a list of words...
Write a class called Book. Here are the relevant attributes: title author yearPublished bookPriceInCAD Provide a constructor that takes parameters to initialize all the instance variables. The constructor calls the mutator (set) methods to initialize the instance variables. Provide an accessor (get) and mutator (set) for each instance variable. The mutators all validate their parameters appropriately and use them only if valid. If the passed parameter was invalid an IllegalArgumentException will be thrown with a proper error message A...
PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a few instance attribute and a few instance methods to support those attributes. In the next assignment, the TripleString class will help us create a more involved application. Before we do that though, we have to thoroughly test our TripleString implementation. Specifications The class TripleString will contain symbolic constants, instance attributes, and instance methods. ▶ Class symbolic constants This class has 3 symbolic constants, which...
PYTHON (A voting machine consists of an election district, together with the names of the candidates and the number of votes cast for each candidate. Define a VotingMachine class, wrote a docstring for the class, and define the following three class methods: 1. An initialization method. The initialization method should: * take a string parameter, electionDistrict, and assign it to the instance attribute elctionDistrict of the voting machine being created. * create an instance attribute named candidates for the voting...
Task 1: 1. Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to an upper bound: the Number class. The class should have as a field an ArrayList of type T. Write the class constructor to create the ArrayList. 2. Write a public method named add, which accepts a parameter of type T. When an argument is passed to the method, add it to the ArrayList. 3. Write a public method...