Answer to Question #279443 in Python for Isabel Cortez

Question #279443

ACT3: Inheritance


INSTRUCTIONS


1. Choose your own category

2. Look for subcategories with similarities or shared attributes (atleast 3 subcategories)

3. Map inheritance on paper, list properties and methods

4. Define PHP classes

5. Inherit, extend, and override properties and methods

6. Create instances to test


Category Ideas: Animals, Clothing, Foods, Furniture, Musical Instruments.




1
Expert's answer
2021-12-14T07:02:30-0500
class Person:
    def __init__(self,name,sex,age):
        self.name = name
        self.age = age
        self.sex = sex

class Cat:
    def __init__(self,name,sex,age):
        self.name = name
        self.age = age
        self.sex = sex

class Dog:
    def __init__(self,name,sex,age):
        self.name = name
        self.age = age
        self.sex = sex

# Inherited usage:
class Aniaml(object):
    def __init__(self,name,sex,age):
            self.name = name
            self.age = age
            self.sex = sex


class Person(Aniaml):
    pass

class Cat(Aniaml):
    pass

class Dog(Aniaml):
    pass

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS