mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
e4e9358a35
commit
7fa920adfc
|
@ -7,11 +7,11 @@ def de_broglie_wavelength(momentum: float, in_ev: bool = False) -> str:
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
momentum (float): Momentum of the particle.
|
momentum (float): Momentum of the particle.
|
||||||
in_ev (bool, optional): True if momentum is in eV·s.
|
in_ev (bool, optional): True if momentum is in eV·s.
|
||||||
If False, momentum is in kg·m/s.
|
If False, momentum is in kg·m/s.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The calculated de Broglie wavelength of the particle in meters,
|
str: The calculated de Broglie wavelength of the particle in meters,
|
||||||
formatted in scientific notation.
|
formatted in scientific notation.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
|
@ -37,7 +37,7 @@ def de_broglie_wavelength(momentum: float, in_ev: bool = False) -> str:
|
||||||
if momentum <= 0:
|
if momentum <= 0:
|
||||||
raise ValueError("Momentum can't be zero or negative.")
|
raise ValueError("Momentum can't be zero or negative.")
|
||||||
|
|
||||||
|
|
||||||
wavelength = PLANCK_CONSTANT_EVS / momentum if in_ev else PLANCK_CONSTANT_JS / momentum
|
wavelength = PLANCK_CONSTANT_EVS / momentum if in_ev else PLANCK_CONSTANT_JS / momentum
|
||||||
return f"{wavelength:.8e}"
|
return f"{wavelength:.8e}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user