The human body has many organs (heart, lungs, brain, and kidney, to name a few). We could think of the human body as complex object made up of simpler objects (organ).
a) Create classes for heart and brain. Think about what the functions of the heart and brain are in our body and map these functions into methods.
b) Create an organ class as the base class for the organs and derive the classes created earlier from the base class.

4 Years
Discussion Span
Last Post by pyTony

I really don't want to sound rude, or like I don't want to help people understant the basics of programming (which I do), but you should probably make an attempt at it before expecting people to just hand you the answers. You haven't even mentioned what part is troubling you.


Just having hard time understand what the question is asking for. I know they want classes, but can you eleborate for me?


You should have a base class called organ. You should also have two other classes called brain and heart, which inherit functionality from the organ class (because both of them are organs).

Basically, for every function the brain or heart carries out, create that function inside the appropriate class. If you can think of any functions that every organ in the body carries out, create that function inside the organ class.


class Organs():

def __int__(self, heart, brain):

    self.heart = heart
    self.brain = brain
def __repr__(self):

    return self.heart()
def __repr__(self):

    return self.brain()

You are still far off. Repeat the basics, read the assignment and explanation you got.

Edited by pyTony

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.