Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help with this in python. im getting an attribute error. 3.6 Program: Pets! In this lab, you will be writing a program with

i need help with this in python. im getting an attribute error. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
3.6 Program: Pets! In this lab, you will be writing a program with classes to keep track of pets. (3 pts) Create a new class called Pet in a file called pet.py. Create a class attribute for the owner's name (called 'pet owner). Since all good pets deserve a name and and have an age, your class should take the name and age from the constructor and assign them to instance variables Your constructor should take parameters in the following order name, age Your instance variables should be called pet name pet_age (2 pts) Override the print method to output a human-friendly version of the object/pet information Example Output Sadie is 6 year(s) old and is owned by Fred (3 pts) in a fie main py, write a main function to test your pet class. The main function should prompt the user for an owner name and then prompt for the names and ages for all pets until the user enters a' or After the entry print out a list of all the pets. Example Output Please enter the owner's name: Steve M. Please enter the pet's name: Fido Please enter the pet's age: 7 Please enter the pet's name: Spot Please enter the pet's age: 1 Please enter the pet's name: Rover Please enter the pet's age: 12 Pet List: Fido is 7 year(s) old and is owned by Steve M. Soots 1 years old and is by Steve Example Output Please enter the owner's name: Steve M. Please enter the pet's name: Fido Please enter the pet's age: 7 Please enter the pet's name: Spot Please enter the pet's age: 1 Please enter the pet's name: Rover Please enter the pet's age: 12 Pet List: Fido is 7 year(s) old and is owned by Steve M. Spot is 1 year(s) old and is owned by Steve M. Rover is 12 year(s) old and is owned by Steve M. ACTIVITY 3.6.1: Program Pets! 3/8 Current file: main.py Load default template. 1 class Pet Owner name "Pet Owner definit_(self name age): self.pet name name self.petage age der str (self): var "() is (1) year(s) old and is owned by (2)".Format(self.pet_name, self.pet_age, Pet owner_name) return var 10 Owner name input("Please enter the owner's name: 11 Pet.owner name owner name 12 petList ] 13 while True: pet name input("Please enter the pet's name:") if pet name or pet name : break age int(input("Please enter the pet's a pet Pet (pet name, age); petlist.append(pet) 3/8 ACTIVITY 3.6.1: Program: Pets! Load default template. Current file: main.py self.pet_age - age det str (self): var 10) 15 (1) year(s) old and is owned by (2)".Format(self.pet_name, self.set_age, Pet owner_rane) return var 18 owner_name=input("Please enter the owner's name:") 11 Pet.owner Owner petlist = 0 13 while True pet name input("Please enter the pet's : ) if pet name or pet name : ageInt(input("Please enter the pet's age :)) pet Pet (pet nane, age); petList.append(pet) 21 print("Pet List") 22 for pet in pet list: print(pet)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions