Question: IN PYTHON 3. This assignment updates code that I already have. I also included an example output below. > import pet pet_owner = input(Please enter
IN PYTHON 3. This assignment updates code that I already have. I also included an example output below.


>
import pet pet_owner = input("Please enter owner's name:") print() pet.Pet.pet_owner = pet_owner pet_list = [] while True: pet_name = input("Please enter the pet's name") print() if pet_name == 'q' or pet_name == 'Q': break age = int(input("Please enter the pet's age")) print() pet_d = pet.Pet(pet_name, age) pet_list.append(pet_d) print("Pet List:") for pet in pet_list: print(pet)
class Pet: pet_owner = "X" def __init__(self, name, age): self.pet_name = name self.pet_age = age def __str__(self): output = "{0} is {1} year(s) old and is owned by {2}".format(self.pet_name, self.pet_age, Pet.pet_owner) return output
![enter owner's name:") print() pet.Pet.pet_owner = pet_owner pet_list = [] while True:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2ed26ecf65_45466f2ed26312bc.jpg)

4.7 Program: Pets! Again In this lab, you will be updating the Pets! program. This uses your program from Chapter 3 as a base, so copy that work into this assignment as a starting point. 1. (3 pts) Create a new class called Dog in pet.py. This class should be a class derived from the Pet class. Create a class attribute in Dog for whether they are house broken (called "house") and initialize it to False (Boolean value). Your Dog constructor should take keyword parameters for dog_name and age dog_age. The default value for name should be "Spot" and for age be 1. 2. (2 pts) Override the print method in Dog to output a human-friendly version of the object/pet information Example Output Dog Sadie is 6 year(s) old, is owned by Fred, and is not house-broken 4. (3 pts) Create a new class called Beagle in pet.py. This class should be a class derived from the Pet and 'Dog'class. Create a class attribute in Beagle for an integer value or ear floppiness (called "flop"). Your Beagle constructor should take keyword parameters for 5. (2 pts) Override the print method in Beagle to output a human-friendly version of the object/pet information. Example Output Beagle Sadie is 6 year(s) old, is owned by Fred, is house-broken, and has an ear floppiness of 7 6.(1 pt) Add a method to Dog called set_flop() to change the integer for ear floppiness. The only argument is an integer to for the new floppiness value. 7. (3 pts) in main.py, modify the main function to test your new classes. The main function loop should prompt the user for an owner, floppiness. Continue until the user enters a 'q' or 'Q! Finally, print out a list of all the current pets. Example Output: Please enter the owner's name: Debbie Please enter the pet's name: Max Please enter the pet's age: 4 Is the dog house-broken? y Is the dog a beagle? n Please enter the owner's name: Louis Please enter the pet's name: Prince Please enter the pet's age: 2 Is the dog house-broken? n Is the dog a beagle? y How floppy are the ears? 7 Please enter the owner's name: Janice Please enter the pet's name: Newton Please enter the pet's age: 8 Is the dog house-broken? n Please enter the owner's name: Q Dog List: Dog Max is 4 year(s) old, is owned by Debbie, and is house-broken Beagle Prince is 2 year(s) old, is owned by Louis, is not house-broken, and has an ear floppiness of 7 Dog Newton is 8 year(s) old, is owned by Janice, and is not house-broken put 10 1 year(s) old and is owned by Stev cover is 12 year(s) old and is owned by ste LAB ACTIVITY 3.6.1: Program: Pets! Curre 5 import pet 6 pet_owner = input("Please enter owner's name:") 7 print() 8 pet.Pet.pet_owner = pet_owner 9 pet_list = [] 10 while True: pet_name = input("Please enter the pet's name") print() 13 if pet_name == 'q' or pet_name == 'Q': 14 break age = int(input("Please enter the pet's age")) print() pet_d = pet.Pet(pet_name, age) 17 18 19 print("Pet List:") 20 for pet in pet_list: 21 print(pet) 22 Submit mode Run your program as ofte. input values in the first bo: Current file: pet.py Loa 2 ## Create your Pet class here O nmin 4 class Pet: pet_owner = "X" def init__(self, name, self.pet_name = name self.pet_age = age def __str_(self): 00 OHM s) old and is owned by {2}".format(self.pet_name, self.pet_age, Pet.pet_owner) return output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
