abc.ABC and @abstractmethod, define PaymentMethod with abstract pay(amount) — so instantiating it raises TypeError — and a concrete subclass UpiPayment implementing pay to return f'paid {amount} via UPI'. ABCs turn "you forgot to override" from a runtime surprise into an instantiation error.PaymentMethod()
TypeError
Abstract classes cannot be instantiated.
UpiPayment().pay(250)
'paid 250 via UPI'
The concrete subclass fulfils the contract.
from abc import ABC, abstractmethod.
The subclass only needs the one method.