Skip to content

Einstein's Energy-Mass Equivalence #9191 #9220

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

Closed
wants to merge 10 commits into from
19 changes: 19 additions & 0 deletions physics/Einstein's Energy-Mass Equivalence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
c = 299792458


def energy_equivalence(mass_kg):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file physics/Einstein's Energy-Mass Equivalence.py, please provide doctest for the function energy_equivalence

Please provide return type hint for the function: energy_equivalence. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: mass_kg

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file physics/Einstein's Energy-Mass Equivalence.py, please provide doctest for the function energy_equivalence

Please provide return type hint for the function: energy_equivalence. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: mass_kg

# Check if the mass is non-negative
if mass < 0:
raise ValueError("mass should be positive")

# Check if the speed of light is positive
if c <= 0:
raise ValueError("Speed of light must be positive")

# Calculate energy using the mass-energy equivalence equation
energy = mass * c**2
return energy


if __name__ == "__main__":
energy_equivalence()