physics · MIT License
Overview
Calculate voltage, current, resistance, and electrical power from exactly two known nonnegative values.
- Tested on a TI calculator
- Downloaded 42 times
- Version 1.0.0
- 5836 bytes
- Uses math
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · tested on OS 5.8.3, Python App 5.8.3.0048
- TI Connect CE .py conversion to a Python AppVar in RAM; physically verified one program at a time
- The component is ohmic and the supplied values describe the same operating point.
- Known values must be nonnegative and required divisor values cannot be zero.
- More or fewer than two known values are rejected.
Try the DuckieDai calculator screen
Follow the reviewed program's real menu, prompts, validation, calculation, and result flow before downloading.
TI-84 Plus CE Python · screen preview
Learn the math
How Ohm's law and electrical power work
The idea
Voltage pushes current through a resistance. Ohm's law ties the three together, and the power formulas tell you how fast energy is being used.
Know any two of voltage, current, resistance, and power and you can find the other two.
The formula
V = I*R
P = I*V
P = I^2*R
P = V^2/R
V- voltage in volts (V)
I- current in amperes (A)
R- resistance in ohms
P- power in watts (W)
Using the program
- The program asks for voltage, current, resistance, and power in turn.
- Type exactly two values and press Enter on the two you do not know.
- It then shows all four quantities across two result screens.
Worked example
A 12 V battery is connected across a 4 ohm resistor. Enter 12 for voltage, leave current blank, enter 4 for resistance, and leave power blank.
I = 12/4 P = 12^2/4
The program shows Current: 3.0 A and Power: 36.0 W.
Tips and common mistakes
- Entering one value or three values is rejected. It must be exactly two.
- Convert milliamps to amps: 250 mA is 0.25 A.
- Power rises with the square of current or voltage, which is why small increases matter.
Where this comes up
This is the foundation of the circuits unit in physics and of any introductory electronics course. Every series and parallel circuit problem comes back to these four formulas.
Exact reviewed bytes
Source code
"""DuckieDai Ohm's Law & Power for TI-84 Plus CE Python."""from math import sqrtdef duckiedai_intro(program_name, wait=True):"""Show the reusable DuckieDai program opening."""title = program_name[:16]empty = 16 - len(title)left = empty // 2right = empty - leftprint("+----------------------+")print("| " + " " * left + title + " " * right + " |")print("| |")print("| __ |")print("| ___(o )> quack! |")print("| \\ <_. ) |")print("| `---' |")print("| by DuckieDai |")print("+----------------------+")print("Loading...")if wait:input("Press enter to start ")print("\n" * 6)def optional_number(prompt):"""Return a nonnegative number or None if blank."""while True:raw = input(prompt)if raw == "":return Nonetry:value = float(raw)if value >= 0 and value < 1e100:return valueexcept ValueError:passprint("Enter 0 or greater")print("or leave blank.")def show_results(v, i, r, p):input("Press enter for results ")print("\n" * 6)print("RESULTS")print()print("Voltage:")print(str(v) + " V")print()print("Current:")print(str(i) + " A")input("Press enter for more ")print("\n" * 6)print("RESULTS CONTINUED")print()print("Resistance:")print(str(r) + " ohms")print()print("Power:")print(str(p) + " W")def main():duckiedai_intro("OHMS LAW")print("OHM'S LAW & POWER")print()print("V = I*R")print("P = I*V")print("P = I^2*R")print("P = V^2/R")input("Press enter for inputs ")print("\n" * 6)print()print("Enter EXACTLY TWO")print("known values.")print()print("Leave unknowns blank.")print()v = optional_number("Voltage V: ")i = optional_number("Current A: ")r = optional_number("Resistance ohm: ")p = optional_number("Power W: ")known = 0if v is not None:known += 1if i is not None:known += 1if r is not None:known += 1if p is not None:known += 1print()if known != 2:print("Enter exactly two")print("known values.")# ==========================================# VOLTAGE + CURRENT## R = V/I# P = V*I# ==========================================elif v is not None and i is not None:if i == 0:print("Cannot determine R")print("when current is 0.")else:r = v / ip = v * iprint("Using:")print("R = V/I")print("P = V*I")show_results(v, i, r, p)# ==========================================# VOLTAGE + RESISTANCE## I = V/R# P = V^2/R# ==========================================elif v is not None and r is not None:if r == 0:print("Resistance cannot")print("be zero.")else:i = v / rp = v ** 2 / rprint("Using:")print("I = V/R")print("P = V^2/R")show_results(v, i, r, p)# ==========================================# CURRENT + RESISTANCE## V = I*R# P = I^2*R# ==========================================elif i is not None and r is not None:if r == 0:print("Resistance cannot")print("be zero.")else:v = i * rp = i ** 2 * rprint("Using:")print("V = I*R")print("P = I^2*R")show_results(v, i, r, p)# ==========================================# POWER + VOLTAGE## I = P/V# R = V^2/P# ==========================================elif p is not None and v is not None:if v == 0 or p == 0:print("Need nonzero V")print("and P to solve.")else:i = p / vr = v ** 2 / pprint("Using:")print("I = P/V")print("R = V^2/P")show_results(v, i, r, p)# ==========================================# POWER + CURRENT## V = P/I# R = P/I^2# ==========================================elif p is not None and i is not None:if i == 0:print("Current cannot")print("be zero.")else:v = p / ir = p / (i ** 2)print("Using:")print("V = P/I")print("R = P/I^2")show_results(v, i, r, p)# ==========================================# POWER + RESISTANCE## I = sqrt(P/R)# V = sqrt(P*R)# ==========================================elif p is not None and r is not None:if r == 0:print("Resistance cannot")print("be zero.")else:i = sqrt(p / r)v = sqrt(p * r)print("Using:")print("I = sqrt(P/R)")print("V = sqrt(P*R)")show_results(v, i, r, p)else:print("Could not solve.")print("Check your values.")print()print("DuckieDai says: done!")# TI-Python imports the selected AppVar rather than# setting __name__ to main.main()
- Filename
OHMSLAW.py- Size
- 5836 bytes
- SHA-256
91be192de445b030b97f4ecd8a6c731bafa2a787ee87f447a16bd056b650c342
Usage
Inputs
- Exactly two known values among voltage, current, resistance, and power; unknown values are left blank
Outputs
- Voltage, current, resistance, and power on paginated result screens
Units: Voltage uses volts, current uses amperes, resistance uses ohms, and power uses watts.
Assumptions and limitations
Assumptions
- The component is ohmic and the supplied values describe the same operating point.
Constraints
- Known values must be nonnegative and required divisor values cannot be zero.
Known failures
- More or fewer than two known values are rejected.
- Non-ohmic or changing circuit conditions are outside the model.
Compatibility and review
- Review status
- Tested on a TI calculator
- Tested on
- TI-84 Plus CE Python; OS 5.8.3; Python App 5.8.3.0048; exact paginated .py transferred through TI Connect CE into RAM and tested individually
- What happened
- Passed: branded intro, known value entry, Ohm law and power calculation, and multi page voltage/current/resistance/power results ran on the physical calculator
- Dependencies
- math
- Suggested calculator name
OHMSLAW— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as OHMSLAW or another name, then open the Python App and try the worked example on this page first.
Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Related learning
Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.