API

Ohms Object

class ohmslaw.Ohms[source]

A class representing basic electrical calculations based on Ohm’s Law.

current(V: float, R: float) float[source]

Calculate current using Ohm’s Law.

Parameters:

V (float): The voltage in volts. R (float): The resistance in ohms.

Returns:

float: The current in amperes.

parallel(*resistors: float) float[source]

Calculate the total resistance of resistors in parallel.

Parameters:

resistors (float): Resistances of the resistors in ohms.

Returns:

float: The total resistance in ohms.

resistance(V: float, I: float) float[source]

Calculate resistance using Ohm’s Law.

Parameters:

V (float): The voltage in volts. I (float): The current in amperes.

Returns:

float: The resistance in ohms.

series(*resistors: float) float[source]

Calculate the total resistance of resistors in series.

Parameters:

resistors (float): Resistances of the resistors in ohms.

Returns:

float: The total resistance in ohms.

volts(I: float, R: float) float[source]

Calculate voltage using Ohm’s Law.

Parameters:

I (float): The current in amperes. R (float): The resistance in ohms.

Returns:

float: The voltage in volts.

watts(I: float, R: float) float[source]

Calculate electrical power in watts using current and resistance.

This method uses the formula P = I^2 * R to calculate electrical power, where P is the power in watts, I is the current in amperes, and R is the resistance in ohms.

Parameters:

Ifloat

Electrical current in amperes (A).

Rfloat

Electrical resistance in ohms (Ω).

Returns:

float

Electrical power in watts (W).

Example:

>>> calculator = Ohms()
>>> power = calculator.watts(3.0, 5.0)
>>> print(power)
45.0