From 4efd5ec4d69f1a765a71890544de6d96f62b942d Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:07:54 +0530 Subject: [PATCH 01/32] Create mass_energy_equivalence.py Einstein's Mass-Energy Equivalence E=MC^2 --- physics/mass_energy_equivalence.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 physics/mass_energy_equivalence.py diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py new file mode 100644 index 000000000000..14a1d7c65028 --- /dev/null +++ b/physics/mass_energy_equivalence.py @@ -0,0 +1,20 @@ +import math +# Function to calculate energy equivalent of a given mass in kilograms using Einstein's equation E=mc^2 +def calculate_energy(mass): + # Speed of light in meters per second (approximately) + speed_of_light = 299792458 + + # Calculate energy using the equation E=mc^2 + energy = mass * math.pow(speed_of_light, 2) + + return energy + +if __name__ == "__main__": + # Input the mass from the user + mass = float(input("Enter mass (in kilograms): ")) + + # Calculate the energy equivalent + energy = calculate_energy(mass) + + # Display the result + print(f"Energy equivalent: {energy} joules") From 6acde009b5a4d5f4422d0235c7099b0bcc1cf73d Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:13:39 +0530 Subject: [PATCH 02/32] Update mass_energy_equivalence.py Einstein's Mass-Energy Equivalence E=MC^2 #9191 --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 14a1d7c65028..da757a90324d 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -1,6 +1,6 @@ import math # Function to calculate energy equivalent of a given mass in kilograms using Einstein's equation E=mc^2 -def calculate_energy(mass): +def calculate_energy(mass): #mass should be in kilograms # Speed of light in meters per second (approximately) speed_of_light = 299792458 From 63cf15d6e259ac522f860d6da39f28ff9a618aae Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:54:24 +0530 Subject: [PATCH 03/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index da757a90324d..5042d400fac3 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -1,13 +1,40 @@ +""" +Mass energy Equivalene +Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence +""" import math -# Function to calculate energy equivalent of a given mass in kilograms using Einstein's equation E=mc^2 -def calculate_energy(mass): #mass should be in kilograms + +# Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2 +def calculate_energy(mass: float) -> float: + """ + get energy equivalent of given mass in joules: + >>> calculate_energy(1.2) + 1.0785062144841811e+17 + + >>> calculate_energy(3.0) + 2.6962655362104528e+17 + + >>> calculate_energy(5) + 4.493775893684088e+17 + + >>> calculate_energy(-5) + Traceback (most recent call last): + ... + raise TypeError("mass cannot negative, less than 0") + TypeError: mass cannot negative, less than 0 + """ + if mass < 0: + raise TypeError("mass cannot negative, less than 0") + # Speed of light in meters per second (approximately) speed_of_light = 299792458 # Calculate energy using the equation E=mc^2 energy = mass * math.pow(speed_of_light, 2) - + + #return value has unit Joules return energy + if __name__ == "__main__": # Input the mass from the user From b7773d2fe1f0e645f2b7d5d630d2aa9664612bda Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:59:24 +0530 Subject: [PATCH 04/32] Update mass_energy_equivalence.py feature#9191 --- physics/mass_energy_equivalence.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 5042d400fac3..f4dbe9f7f2ca 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,20 +3,16 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math - # Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2 def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: >>> calculate_energy(1.2) 1.0785062144841811e+17 - >>> calculate_energy(3.0) 2.6962655362104528e+17 - >>> calculate_energy(5) 4.493775893684088e+17 - >>> calculate_energy(-5) Traceback (most recent call last): ... @@ -24,24 +20,17 @@ def calculate_energy(mass: float) -> float: TypeError: mass cannot negative, less than 0 """ if mass < 0: - raise TypeError("mass cannot negative, less than 0") - + raise TypeError("mass cannot negative, less than 0") # Speed of light in meters per second (approximately) speed_of_light = 299792458 - # Calculate energy using the equation E=mc^2 energy = mass * math.pow(speed_of_light, 2) - #return value has unit Joules return energy - - if __name__ == "__main__": # Input the mass from the user mass = float(input("Enter mass (in kilograms): ")) - # Calculate the energy equivalent energy = calculate_energy(mass) - # Display the result print(f"Energy equivalent: {energy} joules") From 79ccf5ae03b19b9d86d52bbf8bf5567e27981993 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 13:04:02 +0530 Subject: [PATCH 05/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index f4dbe9f7f2ca..7b70eff503ae 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,7 +3,8 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math -# Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2 +""" Function to calculate energy(in joules) equivalent of a given +mass(in kilograms) using Einstein's equation E=mc^2""" def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: From 5a3e9662546e5a6aeec62222bdcfdd32cb6a5f8c Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 13:09:14 +0530 Subject: [PATCH 06/32] Update mass_energy_equivalence.py From fdb0da53b1c34d180847eb950d12f151e9b8e270 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 07:48:39 +0000 Subject: [PATCH 07/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 7b70eff503ae..8d97fcd1509c 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,8 +3,11 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math + """ Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2""" + + def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -21,13 +24,15 @@ def calculate_energy(mass: float) -> float: TypeError: mass cannot negative, less than 0 """ if mass < 0: - raise TypeError("mass cannot negative, less than 0") + raise TypeError("mass cannot negative, less than 0") # Speed of light in meters per second (approximately) speed_of_light = 299792458 # Calculate energy using the equation E=mc^2 energy = mass * math.pow(speed_of_light, 2) - #return value has unit Joules + # return value has unit Joules return energy + + if __name__ == "__main__": # Input the mass from the user mass = float(input("Enter mass (in kilograms): ")) From 4bc3fa1dd22e307032ed803522a70792f880af08 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 14:46:03 +0530 Subject: [PATCH 08/32] Update mass_energy_equivalence.py From 55c8e1f33602f1f3a1d3c89fc636516fd152d649 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 14:46:57 +0530 Subject: [PATCH 09/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 8d97fcd1509c..b54484577e7e 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,11 +3,8 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math - """ Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2""" - - def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: From dbd065c743a19159793dd97ba97173c9685c7703 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 09:17:58 +0000 Subject: [PATCH 10/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index b54484577e7e..8d97fcd1509c 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,8 +3,11 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math + """ Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2""" + + def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: From 90f562fc5252157a64f0bb91f3bcfb8cb0d48a7a Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 14:49:06 +0530 Subject: [PATCH 11/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 8d97fcd1509c..11f6e871bb69 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -2,12 +2,9 @@ Mass energy Equivalene Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ -import math - +import math as m """ Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2""" - - def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -28,11 +25,9 @@ def calculate_energy(mass: float) -> float: # Speed of light in meters per second (approximately) speed_of_light = 299792458 # Calculate energy using the equation E=mc^2 - energy = mass * math.pow(speed_of_light, 2) + energy = mass * m.pow(speed_of_light, 2) # return value has unit Joules return energy - - if __name__ == "__main__": # Input the mass from the user mass = float(input("Enter mass (in kilograms): ")) From 32ca83fb8466051f17be86df02466d7bae6cd1ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 09:20:10 +0000 Subject: [PATCH 12/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 11f6e871bb69..68f55beb85de 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -3,8 +3,11 @@ Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math as m + """ Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's equation E=mc^2""" + + def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -28,6 +31,8 @@ def calculate_energy(mass: float) -> float: energy = mass * m.pow(speed_of_light, 2) # return value has unit Joules return energy + + if __name__ == "__main__": # Input the mass from the user mass = float(input("Enter mass (in kilograms): ")) From 396805b5fd60656d94c4cc1e58a812dd713c4a6a Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:34:11 +0530 Subject: [PATCH 13/32] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 68f55beb85de..b0e5e5d64a90 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -1,5 +1,5 @@ """ -Mass energy Equivalene +Mass-energy equivalence Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence """ import math as m From 46268c1d5690e4f79a3c635e082e8209c8f2b083 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:35:44 +0530 Subject: [PATCH 14/32] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- physics/mass_energy_equivalence.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index b0e5e5d64a90..6ce230d354d8 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -20,11 +20,11 @@ def calculate_energy(mass: float) -> float: >>> calculate_energy(-5) Traceback (most recent call last): ... - raise TypeError("mass cannot negative, less than 0") - TypeError: mass cannot negative, less than 0 + raise TypeError("Mass cannot be negative") + TypeError: Mass cannot be negative """ if mass < 0: - raise TypeError("mass cannot negative, less than 0") + raise TypeError("Mass cannot be negative") # Speed of light in meters per second (approximately) speed_of_light = 299792458 # Calculate energy using the equation E=mc^2 From fc5b639a82a078fc7182e7934347c9c9520ff1e5 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:40:14 +0530 Subject: [PATCH 15/32] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 6ce230d354d8..865f008e6951 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -28,7 +28,7 @@ def calculate_energy(mass: float) -> float: # Speed of light in meters per second (approximately) speed_of_light = 299792458 # Calculate energy using the equation E=mc^2 - energy = mass * m.pow(speed_of_light, 2) + energy = mass * speed_of_light**2 # return value has unit Joules return energy From e2438a64e9ad6b24e8d14fc84808743c8bf9da70 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:41:14 +0530 Subject: [PATCH 16/32] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- physics/mass_energy_equivalence.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 865f008e6951..b4d94fc9b32b 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -34,9 +34,6 @@ def calculate_energy(mass: float) -> float: if __name__ == "__main__": - # Input the mass from the user mass = float(input("Enter mass (in kilograms): ")) - # Calculate the energy equivalent energy = calculate_energy(mass) - # Display the result print(f"Energy equivalent: {energy} joules") From 456f39c61a7d16ed738ea39068002ebf2f447a7e Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:49:07 +0530 Subject: [PATCH 17/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index b4d94fc9b32b..296055fabbef 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -1,13 +1,14 @@ """ Mass-energy equivalence Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence -""" -import math as m - -""" Function to calculate energy(in joules) equivalent of a given -mass(in kilograms) using Einstein's equation E=mc^2""" +Here it defines a Function to calculate energy(in joules) equivalent of a given +mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. +The function takes a single argument mass(in kg) having datatype float and +returns the energy(in joule) having datatype float +""" def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -25,14 +26,10 @@ def calculate_energy(mass: float) -> float: """ if mass < 0: raise TypeError("Mass cannot be negative") - # Speed of light in meters per second (approximately) speed_of_light = 299792458 - # Calculate energy using the equation E=mc^2 energy = mass * speed_of_light**2 - # return value has unit Joules return energy - if __name__ == "__main__": mass = float(input("Enter mass (in kilograms): ")) energy = calculate_energy(mass) From aedc65a07b6aa9172d794c58ef7fdfd97ca003f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 18:19:40 +0000 Subject: [PATCH 18/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 296055fabbef..2994d37c5fd7 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -9,6 +9,8 @@ The function takes a single argument mass(in kg) having datatype float and returns the energy(in joule) having datatype float """ + + def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -30,6 +32,7 @@ def calculate_energy(mass: float) -> float: energy = mass * speed_of_light**2 return energy + if __name__ == "__main__": mass = float(input("Enter mass (in kilograms): ")) energy = calculate_energy(mass) From 832d481da4ebe27021bf8addee9c00c7f3a9cf4d Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:55:35 +0530 Subject: [PATCH 19/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 2994d37c5fd7..8b8a86d81386 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,8 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. +where m is mass and c is the speed of light in vaccume(a constant value) +in meter per second. The function takes a single argument mass(in kg) having datatype float and returns the energy(in joule) having datatype float From 888ba00f15b854b578b5dc20ca7ca2c186880a86 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 18:26:07 +0000 Subject: [PATCH 20/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 8b8a86d81386..e7f7f97692f7 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 393b5227bea6c52e3958836996f5d4fbc8bde475 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Sun, 1 Oct 2023 23:59:30 +0530 Subject: [PATCH 21/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index e7f7f97692f7..8b8a86d81386 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 2ae773644eb095b93c843069873f60a8a60aa864 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 18:30:03 +0000 Subject: [PATCH 22/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 8b8a86d81386..e7f7f97692f7 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 7bca84473d0bf1a1e9a90fb627b818e805d0afa9 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:11:30 +0530 Subject: [PATCH 23/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index e7f7f97692f7..e1b8c16d0c81 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -20,7 +20,7 @@ def calculate_energy(mass: float) -> float: >>> calculate_energy(3.0) 2.6962655362104528e+17 >>> calculate_energy(5) - 4.493775893684088e+17 + 449377589368408820 >>> calculate_energy(-5) Traceback (most recent call last): ... From 11a02a65386cfdf1e5e8b9213cc3e7b1c6bdaf78 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:17:52 +0530 Subject: [PATCH 24/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index e1b8c16d0c81..0619347cab97 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 7542a9ec1566b2ec01921d29ba053370241f7262 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 18:49:08 +0000 Subject: [PATCH 25/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 0619347cab97..e1b8c16d0c81 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) +where m is mass and c is the speed of light in vaccume(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 614a8ec2e8a94ff9dfb873a7a6427eb1ac7ec5d4 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:23:36 +0530 Subject: [PATCH 26/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index e1b8c16d0c81..f1a5dce54b51 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,8 +4,8 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume(a constant value) -in meter per second. +where m is mass and c is the speed of light in vaccume +(a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and returns the energy(in joule) having datatype float From 733fdbedd7ef9300a21324ee69609d181a59184b Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:35:43 +0530 Subject: [PATCH 27/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index f1a5dce54b51..52fc75864b2e 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccume +where m is mass and c is the speed of light in vaccum (a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From a79fbcc46172146c1bcbd12684572e8f20c87b37 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:37:01 +0530 Subject: [PATCH 28/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 52fc75864b2e..7e282abdeae4 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,7 +4,7 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vaccum +where m is mass and c is the speed of light in vacuum (a constant value) in meter per second. The function takes a single argument mass(in kg) having datatype float and From 91b1445a908e0a12e1494c3e5b7398acfbc98101 Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:48:01 +0530 Subject: [PATCH 29/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 7e282abdeae4..79c04480e70e 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -4,14 +4,14 @@ Here it defines a Function to calculate energy(in joules) equivalent of a given mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c is the speed of light in vacuum -(a constant value) in meter per second. +where m is mass and c = 299,792,458 meter per second is the speed of light +in vacuum (a constant value). The function takes a single argument mass(in kg) having datatype float and returns the energy(in joule) having datatype float """ - +speed_of_light = 299792458 def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: @@ -29,7 +29,6 @@ def calculate_energy(mass: float) -> float: """ if mass < 0: raise TypeError("Mass cannot be negative") - speed_of_light = 299792458 energy = mass * speed_of_light**2 return energy From 39969f4dd15f056ab57f282867dd6e7450d4aa38 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 19:18:38 +0000 Subject: [PATCH 30/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/mass_energy_equivalence.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 79c04480e70e..02ab49126814 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -12,6 +12,8 @@ """ speed_of_light = 299792458 + + def calculate_energy(mass: float) -> float: """ get energy equivalent of given mass in joules: From 9c1e53257358e8169633d4dfc4629a7d2dd2b95d Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:02:23 +0530 Subject: [PATCH 31/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index 02ab49126814..b52e8b14c397 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -11,7 +11,7 @@ returns the energy(in joule) having datatype float """ -speed_of_light = 299792458 +SPEED_OF_LIGHT = 299792458 def calculate_energy(mass: float) -> float: @@ -31,7 +31,7 @@ def calculate_energy(mass: float) -> float: """ if mass < 0: raise TypeError("Mass cannot be negative") - energy = mass * speed_of_light**2 + energy = mass * SPEED_OF_LIGHT**2 return energy From 5d1668bce38f8cbb841c65415ba7edff9da415cb Mon Sep 17 00:00:00 2001 From: mhsuhail00 <112853656+mhsuhail00@users.noreply.github.com> Date: Mon, 2 Oct 2023 13:20:21 +0530 Subject: [PATCH 32/32] Update mass_energy_equivalence.py --- physics/mass_energy_equivalence.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/physics/mass_energy_equivalence.py b/physics/mass_energy_equivalence.py index b52e8b14c397..50747794f813 100644 --- a/physics/mass_energy_equivalence.py +++ b/physics/mass_energy_equivalence.py @@ -2,10 +2,9 @@ Mass-energy equivalence Reference: https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence -Here it defines a Function to calculate energy(in joules) equivalent of a given -mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2 -where m is mass and c = 299,792,458 meter per second is the speed of light -in vacuum (a constant value). +This file defines a function to calculate energy (in joules) equivalent to a given +mass (in kilograms) using Einstein's mass-energy equivalence equation E=mc^2, +where m is mass and c = 299,792,458 m/s is the speed of light in a vacuum. The function takes a single argument mass(in kg) having datatype float and returns the energy(in joule) having datatype float