Advanced Assignment: Class, Object, Constructor, and Inheritance
Q1: Create a class 'Matrix' to represent a 2D matrix. Implement methods to add,
subtract, and multiply two matrices. Overload the operators (+, -, *) for these
operations.
Q2: Create a class 'Account' with methods for creating a new account and
maintaining transaction logs. Use a static variable to keep track of the total
number of accounts created.
Q3: Define an abstract base class 'Appliance' with an abstract method
'power_usage'. Derive classes 'WashingMachine' and 'Refrigerator', and
implement the 'power_usage' method in both. Use the ABC module.
Q4: Write a program to demonstrate method overriding and method overloading
in a class hierarchy. Create a base class 'Shape' and derived classes 'Triangle'
and 'Square'.
Q5: Implement a deep and shallow copy of an object using the copy module.
Demonstrate the difference with a class 'Employee' containing a nested
'Address' object.
Q6: Create a class hierarchy to represent a library management system with
classes for 'Library', 'Book', and 'Member'. Add features for borrowing,
returning, and tracking books.
Q7: Define a class 'Robot' with attributes for its position on a 2D grid.
Implement methods to move the robot in different directions and track its path.
Add error handling for invalid movements.
Q8: Write a program to demonstrate the diamond problem in multiple
inheritance and solve it using Python's MRO (Method Resolution Order).
Q9: Create a class 'DataPipeline' with methods for data processing (e.g.,
filtering, transformation). Use method chaining to allow multiple operations in a
single statement.
Q10: Implement a plugin system using Python's inheritance. Create a base
class 'Plugin' and allow users to dynamically add new functionality by
inheriting from this class.