Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I have a Python project to create a class... my code is below, though it's not running? Any help or advice woud be greatly

Hello, I have a Python project to create a "class"... my code is below, though it's not running? Any help or advice woud be greatly aprecciated with a thumbs up. Code is:

class Pet: #initialising the variables def __init__(self, name, aType, age): self.__name = name self.__animal_type = aType self.__age = age #method to assigns a value to the __name field def set_name(self, petName): __name = petName #method to assigns a value to the __animal_type field. def set_animal_type(self, petAType): __animal_type = petAType #method assigns a value to the __age field. def set_age(self, petAge): __age = petAge #method to get the value from the __name field def get_name(self): return __name #method to get the value from the __animal_type field. def get_type(self): return __animal_type #method to get the value from the __age field. def get_age(self): return __age

#main function def main(): #initialize the set with elements p = Pet("","",0) # Ask the user to enter the details of the pet name = input("Enter the name of your pet: ") p.set_name(name) a_type = input("Enter the type of your pet: ") p.set_animal_type(a_type) age = input("Enter the type of your pet: ") p.set_age(age) #display details of the pet print("Your pet name is ", p.get_name) print("Your pet type is ", p.get_type) print("Your pet age is ", p.get_age) main()

input('Press enter to exit.')

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

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago