def is_almost_zero(
        x: float,
        num_of_exponents: int = 6) -> bool:
    """Checks if a num is almost 0 taking into account tiny mistake by python.
    
    Sometimes in adding, division and etc. some mistakes are introduced by
    python. This funcions checks whether a number is 0 taking into account
    with a small desired window of margin. The larger num_of_exponents is, less
    margin for error.

    Args:
        x: The number that we want to be tested.

        num_of_exponents: The number of n for error of 1e-n.

    Returns:
        If the given number is almost zero or not.

    Raises:
        ValueError: When num of exponents were given negative.
    """
    if num_of_exponents < 0:
        raise ValueError('Number of exponents should be positive. '
                         'It was {}'.format(num_of_exponents))
    window_range = 10 ** -num_of_exponents
    return (x >= -window_range) and (x <= window_range)