Comment calculer la puissance à partir du courant et de la tension en Python avec UliEngineering

Vous pouvez facilement calculer la puissance électrique à partir du courant et de la tension à l’aide de la bibliothèque Python UliEngineering :

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

# Calculer la puissance pour 5V à 1A
power = power_by_current_and_voltage("5V", "1A")
print(f"Puissance pour 5V à 1A : {format_value(power, 'W')}")

# Calculer la puissance pour 12V à 0.5A
power = power_by_current_and_voltage("12V", "0.5A")
print(f"Puissance pour 12V à 0.5A : {format_value(power, 'W')}")

Exemple de sortie

power_by_current_and_voltage_output.txt
Puissance pour 5V à 1A : 5.00 W
Puissance pour 12V à 0.5A : 6.00 W

La puissance est calculée à l’aide de la formule : $P = V \times I$

Articles liés


Check out similar posts by category: Electronics, Python