From 770e2f48b83e9d0bb80d492c80feae0ad6acc1e2 Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Sun, 7 May 2023 13:56:51 +0530 Subject: [PATCH 01/14] Create coulomb_law.py --- physics/coulomb_law.py | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 physics/coulomb_law.py diff --git a/physics/coulomb_law.py b/physics/coulomb_law.py new file mode 100644 index 000000000000..2187a312cac1 --- /dev/null +++ b/physics/coulomb_law.py @@ -0,0 +1,53 @@ +""" +Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. + +The unit of Electrostatic force is Newton. + +Coulomb’s Law gives an idea about the force between two point charges. By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. Therefore, we consider them as point charges as it becomes easy for us to calculate the force of attraction/ repulsion between them. + +Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with the theory that the force is inversely proportional to the square of the distance between the charges. He also found that this force is directly proportional to the product of charges (magnitudes only). + +We can show it with the following explanation. Let’s say that there are two charges q1 and q2. The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then + +F ∝ q1q2 + +Or, F ∝ 1/r^2 + +F = k*q1*q2/ r^2 + +where k is proportionality constant and equals to 1/4πε0. + +Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 when we take the S.I unit of value of ε0 is 8.854 × 10^-12 C^2 N^-1 m^-2. + +The unit of Electrostatic force is newton.Mathematically it is written as: +F = (k*q1*q2)/(r**2) + +Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely ,r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . + +https://www.toppr.com/guides/physics/electric-charges-and-fields/coulombs-law/ +""" + +def coulombs_law(q1: float, q2: float, radius: float) -> float: + """ + The Electrostatic Force formula is given as: (k*q1*q2)/(r**2) + >>> round(coulombs_law(15.5,20,15),2) + 12400000000.0 + >>> round(coulombs_law(1,15,5),2) + 5400000000.0 + >>> round(coulombs_law(20,-50,15),2) + -40000000000.0 + >>> round(coulombs_law(-5,-8,10),2) + 3600000000.0 + >>> round(coulombs_law(50,100,50),2) + 18000000000.0 + """ + + if radius <= 0: + raise ValueError("The radius is always a positive non zero integer") + return ((9*10**9)*q1*q2) /(radius**2) + + +if __name__ == "__main__": + import doctest + + doctest.testmod(verbose=True) From 8466f25ea6cc7aa7edb9070d4402b5ac6cc67b8b Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Sun, 7 May 2023 13:58:07 +0530 Subject: [PATCH 02/14] Update coulomb_law.py --- physics/coulomb_law.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/physics/coulomb_law.py b/physics/coulomb_law.py index 2187a312cac1..efed0cc6146a 100644 --- a/physics/coulomb_law.py +++ b/physics/coulomb_law.py @@ -7,7 +7,8 @@ Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with the theory that the force is inversely proportional to the square of the distance between the charges. He also found that this force is directly proportional to the product of charges (magnitudes only). -We can show it with the following explanation. Let’s say that there are two charges q1 and q2. The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then +We can show it with the following explanation. Let’s say that there are two charges q1 and q2. +The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then F ∝ q1q2 @@ -17,12 +18,14 @@ where k is proportionality constant and equals to 1/4πε0. -Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 when we take the S.I unit of value of ε0 is 8.854 × 10^-12 C^2 N^-1 m^-2. +Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 +when we take the S.I unit of value of ε0 is 8.854 × 10^-12 C^2 N^-1 m^-2. The unit of Electrostatic force is newton.Mathematically it is written as: F = (k*q1*q2)/(r**2) -Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely ,r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . +Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely , +r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . https://www.toppr.com/guides/physics/electric-charges-and-fields/coulombs-law/ """ From 07f24ca9bdb5af74f026b170a8e076573282fda8 Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Sun, 7 May 2023 13:59:09 +0530 Subject: [PATCH 03/14] Update coulomb_law.py --- physics/coulomb_law.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/physics/coulomb_law.py b/physics/coulomb_law.py index efed0cc6146a..24ad7254de98 100644 --- a/physics/coulomb_law.py +++ b/physics/coulomb_law.py @@ -1,11 +1,17 @@ """ -Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. +Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. The unit of Electrostatic force is Newton. -Coulomb’s Law gives an idea about the force between two point charges. By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. Therefore, we consider them as point charges as it becomes easy for us to calculate the force of attraction/ repulsion between them. +Coulomb’s Law gives an idea about the force between two point charges. +By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. +Therefore, we consider them as point charges as it becomes easy for us to calculate the force of attraction/ repulsion between them. -Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with the theory that the force is inversely proportional to the square of the distance between the charges. He also found that this force is directly proportional to the product of charges (magnitudes only). +Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with +the theory that the force is inversely proportional to the square of the distance between the charges. +He also found that this force is directly proportional to the product of charges (magnitudes only). We can show it with the following explanation. Let’s say that there are two charges q1 and q2. The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then From 112b1f9696f047fa9b35fdbf767219e0355eecdd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 7 May 2023 08:36:24 +0000 Subject: [PATCH 04/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/coulomb_law.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/physics/coulomb_law.py b/physics/coulomb_law.py index 24ad7254de98..2608ce1d52e4 100644 --- a/physics/coulomb_law.py +++ b/physics/coulomb_law.py @@ -1,19 +1,19 @@ """ -Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges is directly proportional +Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. The unit of Electrostatic force is Newton. -Coulomb’s Law gives an idea about the force between two point charges. -By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. +Coulomb’s Law gives an idea about the force between two point charges. +By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. Therefore, we consider them as point charges as it becomes easy for us to calculate the force of attraction/ repulsion between them. -Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with -the theory that the force is inversely proportional to the square of the distance between the charges. +Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with +the theory that the force is inversely proportional to the square of the distance between the charges. He also found that this force is directly proportional to the product of charges (magnitudes only). -We can show it with the following explanation. Let’s say that there are two charges q1 and q2. +We can show it with the following explanation. Let’s say that there are two charges q1 and q2. The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then F ∝ q1q2 @@ -22,9 +22,9 @@ F = k*q1*q2/ r^2 -where k is proportionality constant and equals to 1/4πε0. +where k is proportionality constant and equals to 1/4πε0. -Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 +Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 when we take the S.I unit of value of ε0 is 8.854 × 10^-12 C^2 N^-1 m^-2. The unit of Electrostatic force is newton.Mathematically it is written as: @@ -36,6 +36,7 @@ https://www.toppr.com/guides/physics/electric-charges-and-fields/coulombs-law/ """ + def coulombs_law(q1: float, q2: float, radius: float) -> float: """ The Electrostatic Force formula is given as: (k*q1*q2)/(r**2) @@ -50,10 +51,10 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: >>> round(coulombs_law(50,100,50),2) 18000000000.0 """ - + if radius <= 0: raise ValueError("The radius is always a positive non zero integer") - return ((9*10**9)*q1*q2) /(radius**2) + return ((9 * 10**9) * q1 * q2) / (radius**2) if __name__ == "__main__": From fdd4eff712e6897f84ccfb43409487649b892731 Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Tue, 9 May 2023 14:25:42 +0530 Subject: [PATCH 05/14] Update and rename coulomb_law.py to coulombs_law.py --- physics/coulomb_law.py | 63 ----------------------------------------- physics/coulombs_law.py | 38 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 63 deletions(-) delete mode 100644 physics/coulomb_law.py create mode 100644 physics/coulombs_law.py diff --git a/physics/coulomb_law.py b/physics/coulomb_law.py deleted file mode 100644 index 2608ce1d52e4..000000000000 --- a/physics/coulomb_law.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. - -The unit of Electrostatic force is Newton. - -Coulomb’s Law gives an idea about the force between two point charges. -By the word point charge, we mean that in physics, the size of linear charged bodies is very small as against the distance between them. -Therefore, we consider them as point charges as it becomes easy for us to calculate the force of attraction/ repulsion between them. - -Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with -the theory that the force is inversely proportional to the square of the distance between the charges. -He also found that this force is directly proportional to the product of charges (magnitudes only). - -We can show it with the following explanation. Let’s say that there are two charges q1 and q2. -The distance between the charges is ‘r’, and the force of attraction/repulsion between them is ‘F’. Then - -F ∝ q1q2 - -Or, F ∝ 1/r^2 - -F = k*q1*q2/ r^2 - -where k is proportionality constant and equals to 1/4πε0. - -Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 -when we take the S.I unit of value of ε0 is 8.854 × 10^-12 C^2 N^-1 m^-2. - -The unit of Electrostatic force is newton.Mathematically it is written as: -F = (k*q1*q2)/(r**2) - -Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely , -r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . - -https://www.toppr.com/guides/physics/electric-charges-and-fields/coulombs-law/ -""" - - -def coulombs_law(q1: float, q2: float, radius: float) -> float: - """ - The Electrostatic Force formula is given as: (k*q1*q2)/(r**2) - >>> round(coulombs_law(15.5,20,15),2) - 12400000000.0 - >>> round(coulombs_law(1,15,5),2) - 5400000000.0 - >>> round(coulombs_law(20,-50,15),2) - -40000000000.0 - >>> round(coulombs_law(-5,-8,10),2) - 3600000000.0 - >>> round(coulombs_law(50,100,50),2) - 18000000000.0 - """ - - if radius <= 0: - raise ValueError("The radius is always a positive non zero integer") - return ((9 * 10**9) * q1 * q2) / (radius**2) - - -if __name__ == "__main__": - import doctest - - doctest.testmod(verbose=True) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py new file mode 100644 index 000000000000..7f1266db493f --- /dev/null +++ b/physics/coulombs_law.py @@ -0,0 +1,38 @@ +""" +Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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 + +where + +k is proportionality constant and equals to 1/4πε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) From 43bd9547943dbd29f47f1513d4d90c7266b2d85e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 08:57:22 +0000 Subject: [PATCH 06/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/coulombs_law.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 7f1266db493f..70074774f8d7 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -5,7 +5,7 @@ F = k*q1*q2/ r^2 -where +where k is proportionality constant and equals to 1/4πε0. q1 is charge of first body (C) @@ -29,7 +29,7 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: """ if radius <= 0: raise ValueError("The radius is always a positive non zero integer") - return ((8.9875517923*10**9) * q1 * q2) / (radius**2) + return ((8.9875517923 * 10**9) * q1 * q2) / (radius**2) if __name__ == "__main__": From 2387620f6a980e013c68c6906ac88d5846ee81ab Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Tue, 9 May 2023 14:32:47 +0530 Subject: [PATCH 07/14] Update coulombs_law.py --- physics/coulombs_law.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 70074774f8d7..fe02807ff3eb 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,13 +1,12 @@ """ -Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges is directly proportional -to the product of the magnitudes of charges and inversely proportional to the square of the distance between them. +The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges +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 -where - -k is proportionality constant and equals to 1/4πε0. +k is proportionality constant and equals 1/4πε0. q1 is charge of first body (C) q2 is charge of second body (C) r is distance between two charged bodies (m) From d7d6517d30dfd4488840208b076a0294cf2f4506 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 09:03:19 +0000 Subject: [PATCH 08/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/coulombs_law.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index fe02807ff3eb..9b98d8486b73 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,5 +1,5 @@ """ -The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges +The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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. From 64fceb5cbea2fd78b5bce04c5fe00ef1045f6542 Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Tue, 9 May 2023 16:49:11 +0530 Subject: [PATCH 09/14] Update coulombs_law.py --- physics/coulombs_law.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 9b98d8486b73..54a5eec667c5 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,12 +1,12 @@ """ -The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges +Coulombs law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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 +F = k*q1*q2/r^2 -k is proportionality constant and equals 1/4πε0. +k is Coulomb's constant and equals 1/(4π*ε0). q1 is charge of first body (C) q2 is charge of second body (C) r is distance between two charged bodies (m) From c78a38460e19c100f508f427b90bc3a8d32056ae Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Fri, 12 May 2023 16:28:30 +0530 Subject: [PATCH 10/14] Update coulombs_law.py --- physics/coulombs_law.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 54a5eec667c5..c6af57c1861a 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,8 +1,11 @@ """ -Coulombs law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges -is directly proportional to the product of the magnitudes of charges and inversely proportional to the square of the distance between them. +Coulombs law states that the magnitude of the electrostatic force of attraction +or repulsion between two point charges 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. +Coulomb studied the repulsive force between bodies having electrical charges +of the same sign. F = k*q1*q2/r^2 From ce65ffbec24dab93805cc5ed94941ab2af21eb9e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 May 2023 10:59:59 +0000 Subject: [PATCH 11/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/coulombs_law.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index c6af57c1861a..78086a55b03c 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,10 +1,10 @@ """ -Coulombs law states that the magnitude of the electrostatic force of attraction -or repulsion between two point charges is directly proportional to the product -of the magnitudes of charges and inversely proportional to the square of the +Coulombs law states that the magnitude of the electrostatic force of attraction +or repulsion between two point charges 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 +Coulomb studied the repulsive force between bodies having electrical charges of the same sign. F = k*q1*q2/r^2 From 1a320400d454d6e665f4fc89312a1b4d91afb611 Mon Sep 17 00:00:00 2001 From: gudlu1925 <120262240+gudlu1925@users.noreply.github.com> Date: Fri, 12 May 2023 16:48:28 +0530 Subject: [PATCH 12/14] Update coulombs_law.py --- physics/coulombs_law.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 78086a55b03c..3ece533a8d62 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,4 +1,5 @@ """ +Description: Coulombs law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges is directly proportional to the product of the magnitudes of charges and inversely proportional to the square of the @@ -13,25 +14,30 @@ q1 is charge of first body (C) q2 is charge of second body (C) r is distance between two charged bodies (m) + +Reference: https://en.wikipedia.org/wiki/Coulomb%27s_law """ def coulombs_law(q1: float, q2: float, radius: float) -> float: """ - >>> round(coulombs_law(15.5,20,15),2) + Calculate the electrostatic force of attraction or repulsion + between two point charges + + >>> coulombs_law(15.5,20,15) 12382849136.06 - >>> round(coulombs_law(1,15,5),2) + >>> coulombs_law(1,15,5) 5392531075.38 - >>> round(coulombs_law(20,-50,15),2) + >>> coulombs_law(20,-50,15) -39944674632.44 - >>> round(coulombs_law(-5,-8,10),2) + >>> coulombs_law(-5,-8,10) 3595020716.92 - >>> round(coulombs_law(50,100,50),2) + >>> coulombs_law(50,100,50) 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) + return round(((8.9875517923 * 10**9) * q1 * q2) / (radius**2),2) if __name__ == "__main__": From ed46580ba11c24b492e23052bcd2e50a2c45dcd2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 May 2023 11:19:36 +0000 Subject: [PATCH 13/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/coulombs_law.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index 3ece533a8d62..a0e0ed194b15 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -23,7 +23,7 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: """ Calculate the electrostatic force of attraction or repulsion between two point charges - + >>> coulombs_law(15.5,20,15) 12382849136.06 >>> coulombs_law(1,15,5) @@ -37,7 +37,7 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: """ if radius <= 0: raise ValueError("The radius is always a positive non zero integer") - return round(((8.9875517923 * 10**9) * q1 * q2) / (radius**2),2) + return round(((8.9875517923 * 10**9) * q1 * q2) / (radius**2), 2) if __name__ == "__main__": From a8bd7cc997f919f2e80073a4be68aa3f1ef3da66 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Wed, 27 Sep 2023 01:39:32 -0400 Subject: [PATCH 14/14] Update coulombs_law.py --- physics/coulombs_law.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/physics/coulombs_law.py b/physics/coulombs_law.py index a0e0ed194b15..252e8ec0f74e 100644 --- a/physics/coulombs_law.py +++ b/physics/coulombs_law.py @@ -1,16 +1,12 @@ """ -Description: -Coulombs law states that the magnitude of the electrostatic force of attraction +Coulomb's law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges 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 -F = k*q1*q2/r^2 - -k is Coulomb's constant and equals 1/(4π*ε0). +k is Coulomb's constant and equals 1/(4π*ε0) q1 is charge of first body (C) q2 is charge of second body (C) r is distance between two charged bodies (m) @@ -24,15 +20,15 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: Calculate the electrostatic force of attraction or repulsion between two point charges - >>> coulombs_law(15.5,20,15) + >>> coulombs_law(15.5, 20, 15) 12382849136.06 - >>> coulombs_law(1,15,5) + >>> coulombs_law(1, 15, 5) 5392531075.38 - >>> coulombs_law(20,-50,15) + >>> coulombs_law(20, -50, 15) -39944674632.44 - >>> coulombs_law(-5,-8,10) + >>> coulombs_law(-5, -8, 10) 3595020716.92 - >>> coulombs_law(50,100,50) + >>> coulombs_law(50, 100, 50) 17975103584.6 """ if radius <= 0: @@ -43,4 +39,4 @@ def coulombs_law(q1: float, q2: float, radius: float) -> float: if __name__ == "__main__": import doctest - doctest.testmod(verbose=True) + doctest.testmod()