Skip to content
CampusEduX

Abstract Shape Hierarchy

Mediumpython
Learn the Concept: Object-Oriented Programming

Create an abstract class Shape with an abstract method area(). Implement Circle and Square subclasses, each providing their own area() calculation, demonstrating polymorphism.

What the problem means: Shape defines that every shape MUST have an area() method, without saying how to calculate it — each concrete shape (Circle, Square) fills in that detail its own way.

Approach: import ABC and abstractmethod from abc; mark Shape's area() with @abstractmethod (no real implementation); Circle and Square each provide their own working area() formula.

Input: Two lines: a circle's radius, then a square's side length.

Output: Two lines: the circle's area, then the square's area.

Related Problems

Input (stdin)

Output

Run your code to see output here...