How to compute current from power and voltage in Python using UliEngineering

You can easily compute current from power and voltage using the UliEngineering Python library:

current_by_power.py
from UliEngineering.Electronics.Power import *
from UliEngineering.EngineerIO import *

# Compute current for 5W at 5V
current = current_by_power("5W", "5V")
print(f"Current for 5W at 5V: {format_value(current, 'A')}")

# Compute current for 6W at 12V
current = current_by_power("6W", "12V")
print(f"Current for 6W at 12V: {format_value(current, 'A')}")

Example output

current_by_power_output.txt
Current for 5W at 5V: 1.00 A
Current for 6W at 12V: 500 mA

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


Check out similar posts by category: Electronics, Python