Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 1.32 KB

MODULE_8.md

File metadata and controls

31 lines (27 loc) · 1.32 KB

Module 8: Exceptions

Module Description

This module focuses on exception handling in Python, including the use of try and except, custom exceptions, and managing errors effectively in code.

Assignment 1: Homework on "Try and Except"

  • Solution
  • Description: Task "Programmers Can Do Everything":
    • Implement a function add_everything_up that can add integers, floats, and strings together. If a number is added to a string, it should return the string representation of both instead of raising a TypeError.

Assignment 2: Homework on "Sum Calculation"

  • Solution
  • Description: Task "Count and Average":
    • Create two functions:
      1. personal_sum to calculate the sum of numeric values in a collection, handling TypeErrors for non-numeric values.
      2. calculate_average to compute the average using personal_sum, handling ZeroDivisionError and TypeError for invalid data types.

Assignment 3: Homework on "Creating Exceptions"

  • Solution
  • Description: Task "Inaccuracy":
    • Implement a Car class with methods for validating VIN and number attributes. Create two custom exception classes, IncorrectVinNumber and IncorrectCarNumbers, to handle validation errors when creating instances of Car.