PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

Abstraction in Python

← All stacks

Theory

58/268

Abstraction in Python

Abstraction means show what the user needs and hide the messy inside. pay() is enough; don’t dump card-number checks into the caller. In Python, ABC can force children to implement methods: from abc import ABC, abstractmethod. A child that forgets the method fails when you instantiate it.

Everyday abstraction is also just a clean method name. ABC is the interview pattern. One sentence: clear interface, hidden internals. Then mention abstractmethod if they push.

Abstraction in Python — output — 12.56. Shape() would fail. Circle fills in area().

Exam tip

ABC idea in one sentence.

Example

# Abstraction
from abc import ABC, abstractmethod

class Shape(ABC):
    @abstractmethod
    def area(self):
        pass

class Circle(Shape):
    def __init__(self, r):
        self.r = r
    def area(self):
        return 3.14 * self.r * self.r

print(Circle(2).area())

Abstraction in Python — output: 12.56. Shape() would fail. Circle fills in area().

Short notes

  • DefHide complexity. Show useful actions.
  • RuleABC + abstractmethod.
  • RememberForce child methods.

Questions

1

Explain Abstraction as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with Abstraction?

Previous← Inheritance in PythonNextEncapsulation in Python →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.