How to compute resistor current from power and resistance in Python using UliEngineering

You can easily compute the current through a resistor given its power dissipation and resistance using the UliEngineering Python library:

resistor_current_by_power.py
from UliEngineering.Electronics.Resistors import *
from UliEngineering.EngineerIO import *

# Compute current for 1W dissipated in 1kΩ resistor
current = resistor_current_by_power("1W", "1k")
print(f"Current for 1W in 1kΩ: {format_value(current, 'A')}")

# Compute current for 0.5W dissipated in 100Ω resistor
current = resistor_current_by_power("0.5W", "100Ω")
print(f"Current for 0.5W in 100Ω: {format_value(current, 'A')}")

Example output

resistor_current_by_power_output.txt
Current for 1W in 1kΩ: 31.6 mA
Current for 0.5W in 100Ω: 70.7 mA

The current is computed using the formula: $I = \sqrt{\frac{P}{R}}$


Check out similar posts by category: Electronics, Python