https byjus comequivalentresistanceformula req 1 1r1 1r2 1rn resistorparallel3 21389 2 3 0 8737571620498019 resistorparallel3 21389 2 3 traceback most recent call last valueerror resistor at index 2 has a negative or zero value resistorparallel3 21389 2 0 000 traceback most recent call last valueerror resistor at index 2 has a negative or zero value req r1 r2 rn calculate the equivalent resistance for any number of resistors in parallel resistorseries3 21389 2 3 8 21389 resistorseries3 21389 2 3 traceback most recent call last valueerror resistor at index 2 has a negative value https byjus com equivalent resistance formula req 1 1 r1 1 r2 1 rn resistor_parallel 3 21389 2 3 0 8737571620498019 resistor_parallel 3 21389 2 3 traceback most recent call last valueerror resistor at index 2 has a negative or zero value resistor_parallel 3 21389 2 0 000 traceback most recent call last valueerror resistor at index 2 has a negative or zero value req r1 r2 rn calculate the equivalent resistance for any number of resistors in parallel resistor_series 3 21389 2 3 8 21389 resistor_series 3 21389 2 3 traceback most recent call last valueerror resistor at index 2 has a negative value
from __future__ import annotations


def resistor_parallel(resistors: list[float]) -> float:
    

    first_sum = 0.00
    index = 0
    for resistor in resistors:
        if resistor <= 0:
            msg = f"Resistor at index {index} has a negative or zero value!"
            raise ValueError(msg)
        first_sum += 1 / float(resistor)
        index += 1
    return 1 / first_sum


def resistor_series(resistors: list[float]) -> float:
    
    sum_r = 0.00
    index = 0
    for resistor in resistors:
        sum_r += resistor
        if resistor < 0:
            msg = f"Resistor at index {index} has a negative value!"
            raise ValueError(msg)
        index += 1
    return sum_r


if __name__ == "__main__":
    import doctest

    doctest.testmod()