🔁 Polymorphism in Python
Program 1: Calculator – Method Overloading using Default Arguments
Problem Statement:
Create a class Calculator with a method add() that can add two or three numbers using default
arguments.
Simulate function overloading by calling the same method with different number of arguments.
Sample Output:
Addition of 2 numbers: 9
Addition of 3 numbers: 15
*Program 2: Area Calculation – Method Overloading using args
Problem Statement:
Create a class Area with a method calculate() using *args.
• If 1 argument → calculate area of square
• If 2 arguments → calculate area of rectangle
• If 3+ arguments → display error message
Sample Output:
Area of Square: 25
Area of Rectangle: 24
Invalid number of arguments
Program 3: Payment Gateway System
Problem Statement:
Design a payment system using polymorphism.
Create a base class Payment with a method make_payment().
Override this method in subclasses: CreditCard, DebitCard, and UPI.
Each subclass processes the payment in its own way.
Sample Output:
Processing ₹500 payment using Credit Card.
Processing ₹300 payment using Debit Card.
Processing ₹150 payment via UPI (Google Pay, PhonePe).
Program 4: Employee Bonus System
Problem Statement:
Build a bonus calculation system using polymorphism.
Create a base class Employee with a method get_bonus().
Override this method in subclasses: Manager, Developer, and Intern.
Return different bonuses based on employee type.
Sample Output:
Manager gets a bonus of ₹20000
Developer gets a bonus of ₹10000
Intern gets a bonus of ₹3000