Как вычислить мощность по току и напряжению на Python с помощью UliEngineering

Можно легко вычислить электрическую мощность по току и напряжению с помощью библиотеки Python UliEngineering:

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button.
V
A
power_by_current_and_voltage.py
from UliEngineering.Electronics.Power import *
from UliEngineering.EngineerIO import *

# Вычислить мощность для 5 В при 1 А
power = power_by_current_and_voltage("5V", "1A")
print(f"Power for 5V at 1A: {format_value(power, 'W')}")

# Вычислить мощность для 12 В при 0.5 А
power = power_by_current_and_voltage("12V", "0.5A")
print(f"Power for 12V at 0.5A: {format_value(power, 'W')}")

Пример вывода

power_by_current_and_voltage_output.txt
Power for 5V at 1A: 5.00 W
Power for 12V at 0.5A: 6.00 W

Мощность вычисляется по формуле: $P = V \times I$

Связанные записи


Check out similar posts by category: Calculators, Electronics, Python