Jak vypočítat výkon z proudu a napětí v Pythonu pomocí UliEngineering

Můžete snadno vypočítat elektrický výkon z proudu a napětí pomocí knihovny UliEngineering v Pythonu:

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 *

# Výpočet výkonu pro 5V při 1A
power = power_by_current_and_voltage("5V", "1A")
print(f"Power for 5V at 1A: {format_value(power, 'W')}")

# Výpočet výkonu pro 12V při 0.5A
power = power_by_current_and_voltage("12V", "0.5A")
print(f"Power for 12V at 0.5A: {format_value(power, 'W')}")

Příklad výstupu

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

Výkon se počítá pomocí vzorce: $P = V \times I$

Související příspěvky


Podívejte se na podobné články podle kategorie: Calculators, Electronics, Python