How to compute current through resistor in Python using UliEngineering
You can easily compute the current flowing through a resistor using Ohm’s law with the UliEngineering Python library:
current_through_resistor.py
from UliEngineering.Electronics.Resistors import *
from UliEngineering.EngineerIO import *
# Compute current through 1kΩ resistor at 5V
current = current_through_resistor("5V", "1k")
print(f"Current through 1kΩ at 5V: {format_value(current, 'A')}")
# Compute current through 100Ω resistor at 3.3V
current = current_through_resistor("3.3V", "100Ω")
print(f"Current through 100Ω at 3.3V: {format_value(current, 'A')}")Example output
current_through_resistor_output.txt
Current through 1kΩ at 5V: 5.00 mA
Current through 100Ω at 3.3V: 33.0 mAThe current is computed using Ohm’s law: $I = \frac{V}{R}$
Related posts
- How to compute voltage across resistor in Python using UliEngineering
- How to compute resistor value from voltage and current in Python using UliEngineering
- How to compute power from current and voltage 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