Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I am learning python and I am not able to understand the below statement: 

"The function (including its name) can capture our mental chunking, or abstraction, of the problem."

1 Answer

0 votes
by (108k points)

Please be informed that Abstracting means to give titles to things so that the name captures the focus of what a function or a whole code does. A great way to experience abstraction is through abstract classes.

Let's suppose we are having a code that models a house. The house will have many different rooms, which we will denote as objects. We set a class for a Bathroom, Kitchen, Living Room, Dining Room, etc.

But, all of these are Rooms and thus share many properties (# of doors/windows, square feet, etc.) BUT, a Room can never exist on its own...it's always going to be some type of room.

Then it is reasonable to create an abstract class called Room, which will contain the properties all rooms share, and then have the classes of Kitchen, Living Room, etc, inherit the abstract class Room.

The thought of a room is abstract and only exists in our head because any room that actually exists isn't just a room; it's a bedroom or a living room or a classroom.

If you are a beginner and want to know more about Python, then do refer to the python tutorial that will help you out in a better way. 

Related questions

0 votes
1 answer
asked Dec 24, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 11, 2021 in Python by Rekha (2.2k points)
0 votes
1 answer
asked Feb 4, 2021 in Python by Rekha (2.2k points)
0 votes
1 answer
asked Dec 16, 2020 in Python by ashely (50.2k points)

Browse Categories

...