source the arrl handbook for radio communications https en wikipedia orgwikirlcircuit description inductor is a passive electronic device which stores energy but unlike capacitor it stores energy in its magnetic field or magnetostatic field when inductor is connected to dc current source nothing happens it just works like a wire because it s real effect cannot be seen while dc is connected its not even going to store energy inductor stores energy only when it is working on ac current connecting a inductor in series with a resistorwhen r 0 to a ac potential source from zero to a finite value causes a sudden voltage to induced in inductor which opposes the current which results in initially slowly current rise however it would cease if there is no further changes in current with resistance zero current will never stop rising resistanceohms inductancehenrys is known as rltimeconstant it also represents as tau while the charging of a inductor with a resistor results in a exponential function when inductor is connected across ac potential source it starts to store the energy in its magnetic field with the help rltimeconstant we can find current at any time in inductor while it is charging find inductor current at any nth second after initiating its charging examples charginginductorsourcevoltage5 8 resistance1 5 inductance2 3 time2 2 817 charginginductorsourcevoltage8 resistance5 inductance3 time2 1 543 charginginductorsourcevoltage8 resistance5pow10 2 inductance3 time2 0 016 charginginductorsourcevoltage8 resistance100 inductance15 time12 traceback most recent call last valueerror source voltage must be positive charginginductorsourcevoltage80 resistance15 inductance100 time5 traceback most recent call last valueerror resistance must be positive charginginductorsourcevoltage12 resistance200 inductance20 time5 traceback most recent call last valueerror inductance must be positive charginginductorsourcevoltage0 resistance200 inductance20 time5 traceback most recent call last valueerror source voltage must be positive charginginductorsourcevoltage10 resistance0 inductance20 time5 traceback most recent call last valueerror resistance must be positive charginginductorsourcevoltage15 resistance25 inductance0 time5 traceback most recent call last valueerror inductance must be positive source the arrl handbook for radio communications https en wikipedia org wiki rl_circuit description inductor is a passive electronic device which stores energy but unlike capacitor it stores energy in its magnetic field or magnetostatic field when inductor is connected to dc current source nothing happens it just works like a wire because it s real effect cannot be seen while dc is connected its not even going to store energy inductor stores energy only when it is working on ac current connecting a inductor in series with a resistor when r 0 to a ac potential source from zero to a finite value causes a sudden voltage to induced in inductor which opposes the current which results in initially slowly current rise however it would cease if there is no further changes in current with resistance zero current will never stop rising resistance ohms inductance henrys is known as rl timeconstant it also represents as τ tau while the charging of a inductor with a resistor results in a exponential function when inductor is connected across ac potential source it starts to store the energy in its magnetic field with the help rl time constant we can find current at any time in inductor while it is charging value of exp 2 718281828459 source_voltage should be in volts resistance should be in ohms inductance should be in henrys time should in seconds find inductor current at any nth second after initiating its charging examples charging_inductor source_voltage 5 8 resistance 1 5 inductance 2 3 time 2 2 817 charging_inductor source_voltage 8 resistance 5 inductance 3 time 2 1 543 charging_inductor source_voltage 8 resistance 5 pow 10 2 inductance 3 time 2 0 016 charging_inductor source_voltage 8 resistance 100 inductance 15 time 12 traceback most recent call last valueerror source voltage must be positive charging_inductor source_voltage 80 resistance 15 inductance 100 time 5 traceback most recent call last valueerror resistance must be positive charging_inductor source_voltage 12 resistance 200 inductance 20 time 5 traceback most recent call last valueerror inductance must be positive charging_inductor source_voltage 0 resistance 200 inductance 20 time 5 traceback most recent call last valueerror source voltage must be positive charging_inductor source_voltage 10 resistance 0 inductance 20 time 5 traceback most recent call last valueerror resistance must be positive charging_inductor source_voltage 15 resistance 25 inductance 0 time 5 traceback most recent call last valueerror inductance must be positive
from math import exp  


def charging_inductor(
    source_voltage: float,  
    resistance: float,  
    inductance: float,  
    time: float,  
) -> float:
    

    if source_voltage <= 0:
        raise ValueError("Source voltage must be positive.")
    if resistance <= 0:
        raise ValueError("Resistance must be positive.")
    if inductance <= 0:
        raise ValueError("Inductance must be positive.")
    return round(
        source_voltage / resistance * (1 - exp((-time * resistance) / inductance)), 3
    )


if __name__ == "__main__":
    import doctest

    doctest.testmod()