How to compute power from current and voltage in Python using UliEngineering
You can easily compute electrical power from current and voltage using the UliEngineering Python library:
power_by_current_and_voltage.py
from UliEngineering.Electronics.Power import *
from UliEngineering.EngineerIO import *
# Compute power for 5V at 1A
power = power_by_current_and_voltage("5V", "1A")
print(f"Power for 5V at 1A: {format_value(power, 'W')}")
# Compute power for 12V at 0.5A
power = power_by_current_and_voltage("12V", "0.5A")
print(f"Power for 12V at 0.5A: {format_value(power, 'W')}")Example output
power_by_current_and_voltage_output.txt
Power for 5V at 1A: 5.00 W
Power for 12V at 0.5A: 6.00 WThe power is computed using the formula: $P = V \times I$
Related posts
- How to compute current through resistor in Python using UliEngineering
- How to compute voltage across resistor in Python using UliEngineering
- How to compute resistor value from voltage and current in Python using UliEngineering
Check out similar posts by category:
Electronics, Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow