-
Function Overloading:
- Create a class called
MathOperationswith methods for addition and multiplication. - Implement function overloading by creating methods with the same name but different parameter types.
- Demonstrate the use of both methods by creating an object of the class and calling each method.
- Create a class called
-
Operator Overloading:
- Create a class called
ComplexNumberto represent complex numbers. - Implement the
__add__method to overload the addition operator for complex numbers. - Create two objects of the class and demonstrate the use of the
+operator for complex number addition.
- Create a class called
-
Division by Zero Handling:
- Write a function that takes two numbers as input and performs division.
- Implement exception handling to catch a
ZeroDivisionErrorif the second number is zero. - Print an appropriate error message in case of an exception.
-
File Handling with Try-Except:
- Modify the file reading assignment from earlier to include exception handling.
- Use a try-except block to catch and print any
FileNotFoundErrorthat may occur.
-
Module Creation:
- Create a Python module named
calculatorthat contains functions for addition, subtraction, multiplication, and division. - Import and use this module in a separate script to perform calculations.
- Create a Python module named
-
Custom Exception Module:
- Create a module named
custom_exceptionsthat defines a custom exception classInvalidInputError. - Use this module in a script to raise and catch instances of the custom exception.
- Create a module named
- Encourage students to use meaningful variable names and provide comments explaining their code.
- Remind students to handle exceptions gracefully, providing informative error messages.
- Emphasize the importance of proper module organization and usage.
- Encourage experimentation with different scenarios to ensure the correctness of the code.
- Provide feedback on the usage of polymorphism, exception handling, and modules in their solutions.