def area(self): return self.width * self.height
print(rectangle.area()) # Output: 20 print(circle.area()) # Output: 28.26
class PayPalPaymentGateway(PaymentGateway): def process_payment(self, amount): print(f"Processing payment of ${amount} using PayPal.")
class StripePaymentGateway(PaymentGateway): def process_payment(self, amount): print(f"Processing payment of ${amount} using Stripe.")
from abc import ABC, abstractmethod
class Circle(Shape): def __init__(self, radius): self.radius = radius
rectangle = Rectangle(4, 5) circle = Circle(3)
Encapsulation is the concept of hiding the internal implementation details of an object from the outside world. This is achieved by using access modifiers such as public, private, and protected.