physics · MIT License
Overview
Solve electric force, either charge magnitude, or separation distance using Coulomb's law and identify attraction or repulsion when charge signs are known.
- Tested on a TI calculator
- Downloaded 44 times
- Version 1.0.0
- 5856 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
- Charges are treated as point charges and ke is 8.988E9.
- Distance and force magnitudes must be positive; divisor values cannot be zero.
- Force magnitude alone cannot determine an unknown charge's sign.
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 Coulomb's law works
The idea
Electric charges push or pull on each other. The force grows with the size of each charge and drops quickly as they move apart: twice the distance gives one quarter of the force.
Charges with the same sign repel. Charges with opposite signs attract.
The formula
Fe = ke*|q1*q2|/r^2
Fe- size of the electric force (N)
ke- 8.988 x 10^9 N*m^2/C^2, built into the program
q1, q2- the two charges in coulombs (C)
r- distance between the charges (m)
Using the program
- Choose what to solve for: 1 force, 2 charge 1, 3 charge 2, or 4 distance.
- Enter the known values. For a force calculation the program also tells you whether the force is attractive or repulsive.
Worked example
Two charges of 2 microcoulombs and 3 microcoulombs sit 0.5 m apart. Choose 1 and enter 0.000002, 0.000003, and 0.5.
The program shows Fe = 0.2157 newtons (it prints more decimal places) and Force type: REPULSIVE, because both charges are positive.
Tips and common mistakes
- Convert microcoulombs to coulombs before typing: 1 microcoulomb is 0.000001 C.
- Type a negative sign for a negative charge so the program can tell you the direction.
- Distance is squared, so a small error in r makes a large error in the force.
Where this comes up
It opens the electricity unit in high school physics and second-semester college physics. General chemistry uses the same idea to explain ionic bonding and lattice energy.
Exact reviewed bytes
Source code
"""DuckieDai Coulomb's Law 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 number(prompt):"""Allow positive or negative finite numbers."""while True:try:value = float(input(prompt))if value > -1e100 and value < 1e100:return valueexcept ValueError:passprint("Enter a valid number.")def nonzero_number(prompt):"""Require a number other than zero."""while True:value = number(prompt)if value != 0:return valueprint("Value cannot be zero.")def positive_number(prompt):"""Require a number greater than zero."""while True:try:value = float(input(prompt))if value > 0 and value < 1e100:return valueexcept ValueError:passprint("Enter a number above 0.")def show_answer(name, value, unit):input("Press enter for answer ")print("\n" * 6)print("ANSWER")print(name + " = " + str(value))print(unit)def force_type(q1, q2):"""Tell whether two charges attract or repel."""if q1 * q2 < 0:return "ATTRACTIVE"else:return "REPULSIVE"def main():duckiedai_intro("COULOMBS LAW")ke = 8.988e9print("COULOMB'S LAW")print()print("Formula:")print("Fe = ke*|q1*q2|/r^2")print()print("ke = 8.988E9")input("Press enter for menu ")print("\n" * 6)print()print("What do you need?")print()print("1. Electric force")print("2. Charge 1")print("3. Charge 2")print("4. Distance")print()choice = input("Choose 1-4: ")print()# ==========================================# 1. SOLVE ELECTRIC FORCE## Fe = ke*|q1*q2|/r^2# ==========================================if choice == "1":q1 = nonzero_number("Charge 1 (C): ")q2 = nonzero_number("Charge 2 (C): ")r = positive_number("Distance (m): ")force = (ke * abs(q1 * q2) /(r ** 2))print()print("Using:")print("Fe = ke*|q1*q2|/r^2")show_answer("Fe",force,"newtons")print()print("Force type:")print(force_type(q1, q2))# ==========================================# 2. SOLVE MAGNITUDE OF CHARGE 1## |q1| = Fe*r^2 / (ke*|q2|)# ==========================================elif choice == "2":force = positive_number("Force (N): ")q2 = nonzero_number("Charge 2 (C): ")r = positive_number("Distance (m): ")q1 = (force * r ** 2 /(ke * abs(q2)))print()print("Using:")print("Fe = ke*|q1*q2|/r^2")print()print("Rearranged:")print("|q1| = Fe*r^2")print(" /(ke*|q2|)")show_answer("|q1|",q1,"coulombs")print()print("Note:")print("Force alone cannot")print("determine q1 sign.")# ==========================================# 3. SOLVE MAGNITUDE OF CHARGE 2## |q2| = Fe*r^2 / (ke*|q1|)# ==========================================elif choice == "3":force = positive_number("Force (N): ")q1 = nonzero_number("Charge 1 (C): ")r = positive_number("Distance (m): ")q2 = (force * r ** 2 /(ke * abs(q1)))print()print("Using:")print("Fe = ke*|q1*q2|/r^2")print()print("Rearranged:")print("|q2| = Fe*r^2")print(" /(ke*|q1|)")show_answer("|q2|",q2,"coulombs")print()print("Note:")print("Force alone cannot")print("determine q2 sign.")# ==========================================# 4. SOLVE DISTANCE## r = sqrt(ke*|q1*q2|/Fe)# ==========================================elif choice == "4":force = positive_number("Force (N): ")q1 = nonzero_number("Charge 1 (C): ")q2 = nonzero_number("Charge 2 (C): ")r = sqrt(ke * abs(q1 * q2) /force)print()print("Using:")print("Fe = ke*|q1*q2|/r^2")print()print("Rearranged:")print("r = sqrt(")print("ke*|q1*q2|/Fe)")show_answer("r",r,"meters")print()print("Force type:")print(force_type(q1, q2))else:print("Invalid choice.")print()print("DuckieDai says: done!")# TI-Python imports the selected AppVar rather than# setting __name__ to main.main()
- Filename
COULOMB.py- Size
- 5856 bytes
- SHA-256
b569e112c44626a91e96f49630b52a1821bb5f1f996fc577b7c7a3e76eb47c2c
Usage
Inputs
- Requested unknown: electric force, charge 1, charge 2, or distance
- Known charges in coulombs and distance in metres
Outputs
- Requested value and, when both charge signs are supplied, attractive or repulsive force type
Units: Charges use coulombs, distance uses metres, and force uses newtons.
Assumptions and limitations
Assumptions
- Charges are treated as point charges and ke is 8.988E9.
Constraints
- Distance and force magnitudes must be positive; divisor values cannot be zero.
Known failures
- Force magnitude alone cannot determine an unknown charge's sign.
- Inconsistent units produce an incorrect result.
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, paginated menu, Coulomb law workflow, force type output, and answer screen ran on the physical calculator
- Dependencies
- math
- Suggested calculator name
COULOMB— 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 COULOMB 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.