Computers and Technology

The following block of code is used in each part of the exercise. It is repeated for readability. 1| class Dog: 2| def __init__(self, name = "", owner = None): 3| self. name = name 4| self. owner = owner 5| def speak(self): 6| print("WOOF!") 7| 8| class Owner: 9| def __init__(self, name): 10| self. name = name 11| def speak(self): 12| print("My name is:", name) Imagine that we have applied the fix from Part 3 to this code. Then, imagine that after that class definition, we wrote the following code: 14| owner1 = Owner("David") 15| owner2 = Owner("Priyank") 16| dog1 = Dog("Fido", owner1) 17| dog2 = Dog("Barkley", owner2) 18| dog3 = Dog("Spot", owner2) 19| dog4 = Dog() 20| newList = [owner1, dog1, owner2, dog2, dog3, dog4] 21| for item in newList: 22| print(item. speak()) What would this code print?

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:00, azainababbas
Sam is a data analyst at an advertising firm. he often uses a spreadsheet that contains media ratings details. he would like to filter the spreadsheet data based on different filter criteria. which operators can he use to specify the combination of filter criteria? sam can use the ( blank ) operators to specify a combination of filter criteria.
Answers: 3
image
Computers and Technology, 23.06.2019 18:40, cyn95xx
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
image
Computers and Technology, 24.06.2019 16:30, magalya01
Which program can damage your computer?
Answers: 1
image
Computers and Technology, 24.06.2019 16:50, bella7524
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
Do you know the correct answer?
The following block of code is used in each part of the exercise. It is repeated for readability. 1|...

Questions in other subjects:

Konu
Mathematics, 04.02.2020 08:55