Skip to content

Added Coulomb_Law #8714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 27, 2023
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions physics/coulombs_law.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges
Coulomb's law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges

For clarity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line no.2,3,5 should be break into multiple as it is long ....use 'ruff . --fix'

is directly proportional to the product of the magnitudes of charges and inversely proportional to the square of the distance between them.

Coulomb studied the repulsive force between bodies having electrical charges of the same sign.

F = k*q1*q2/ r^2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
F = k*q1*q2/ r^2
F = k*q1*q2/r^2

Spacing


k is proportionality constant and equals 1/4πε0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k is proportionality constant and equals 1/4πε0.
k is the Coulomb constant and equals 1/(4π * ε0).

According to Wikipedia, $k$ is called the Coulomb constant

Added parentheses for clarity, because otherwise it looks like $\frac{1}{4} \pi \varepsilon_0$ and not $\frac{1}{4 \pi \varepsilon_0}$

q1 is charge of first body (C)
q2 is charge of second body (C)
r is distance between two charged bodies (m)
"""


def coulombs_law(q1: float, q2: float, radius: float) -> float:
"""
>>> round(coulombs_law(15.5,20,15),2)
12382849136.06
>>> round(coulombs_law(1,15,5),2)
5392531075.38
>>> round(coulombs_law(20,-50,15),2)
-39944674632.44
>>> round(coulombs_law(-5,-8,10),2)
3595020716.92
>>> round(coulombs_law(50,100,50),2)
17975103584.6
"""
if radius <= 0:
raise ValueError("The radius is always a positive non zero integer")
return ((8.9875517923 * 10**9) * q1 * q2) / (radius**2)


if __name__ == "__main__":
import doctest

doctest.testmod(verbose=True)