Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Assignment 19: Polymorphism

  1. Function Overloading:

    • Create a class called MathOperations with 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.
  2. Operator Overloading:

    • Create a class called ComplexNumber to 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.

Assignment 20: Exception Handling

  1. Division by Zero Handling:

    • Write a function that takes two numbers as input and performs division.
    • Implement exception handling to catch a ZeroDivisionError if the second number is zero.
    • Print an appropriate error message in case of an exception.
  2. 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 FileNotFoundError that may occur.

Assignment 21: Modules

  1. Module Creation:

    • Create a Python module named calculator that contains functions for addition, subtraction, multiplication, and division.
    • Import and use this module in a separate script to perform calculations.
  2. Custom Exception Module:

    • Create a module named custom_exceptions that defines a custom exception class InvalidInputError.
    • Use this module in a script to raise and catch instances of the custom exception.

Instructions:

  • 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.