mobts.divider package
Submodules
mobts.divider.divider module
Module for division operations with custom exceptions.
This module provides a function for performing division and raises a custom exception when attempting to divide by zero.
Functions
- divide(a, b)
Divide two numbers, raising a custom exception if the divisor is zero.
Exceptions
- CantDivideByZeroError
Raised when an attempt is made to divide by zero.
- mobts.divider.divider.divide(a, b)
Divide two numbers, raising a custom exception if the divisor is zero.
- Parameters:
a (float) – The dividend.
b (float) – The divisor.
- Returns:
The result of the division.
- Return type:
float
- Raises:
CantDivideByZeroError – If the divisor (b) is zero.
Examples
>>> divide(10, 2) 5.0 >>> divide(10, 0) Traceback (most recent call last): ... CantDivideByZeroError
mobts.divider.divider_error module
Module for custom exceptions related to calculator operations.
This module defines custom exceptions used in calculator operations, including a base exception class and a specific exception for division by zero errors.
Classes
- CalculatorError
Base class for exceptions in calculator operations.
- CantDivideByZeroError
Exception raised when an attempt is made to divide by zero.
Exceptions
- CalculatorError
Base class for exceptions in the calculator domain.
- CantDivideByZeroError
Raised specifically for division by zero errors.
- exception mobts.divider.divider_error.CalculatorError(*args)
Bases:
ExceptionBase class for exceptions in calculator operations.
This class is intended to be used as a base class for other calculator-related exceptions. It inherits from the built-in Exception class and allows for custom exception handling in the calculator domain.
- Parameters:
args (tuple) – Variable length argument list passed to the base Exception class.
- exception mobts.divider.divider_error.CantDivideByZeroError
Bases:
CalculatorErrorException raised when an attempt is made to divide by zero.
This exception is a specific subclass of CalculatorError and is intended to be used when a division by zero error occurs. It provides a custom error message indicating that division by zero is not allowed.
- Parameters:
None
Notes
The default message for this exception is “tu ne peux pas diviser par zéro”.
Module contents
Module for division operations and custom exceptions.
This module provides functions and exceptions related to division operations. It imports the divide function and the CantDivideByZeroError exception from other modules and makes them available for use in this module.
Functions
- divide(a, b)
Divide two numbers, raising a custom exception if the divisor is zero.
Exceptions
- CantDivideByZeroError
Raised when an attempt is made to divide by zero.
Imports
divide: Function for performing division operations.
CantDivideByZeroError: Exception raised for division by zero errors.
- exception mobts.divider.CantDivideByZeroError
Bases:
CalculatorErrorException raised when an attempt is made to divide by zero.
This exception is a specific subclass of CalculatorError and is intended to be used when a division by zero error occurs. It provides a custom error message indicating that division by zero is not allowed.
- Parameters:
None
Notes
The default message for this exception is “tu ne peux pas diviser par zéro”.
- mobts.divider.divide(a, b)
Divide two numbers, raising a custom exception if the divisor is zero.
- Parameters:
a (float) – The dividend.
b (float) – The divisor.
- Returns:
The result of the division.
- Return type:
float
- Raises:
CantDivideByZeroError – If the divisor (b) is zero.
Examples
>>> divide(10, 2) 5.0 >>> divide(10, 0) Traceback (most recent call last): ... CantDivideByZeroError