>>> rms_speed_of_molecule(100, 2) 35.315279554323226 >>> rms_speed_of_molecule(273, 12) 23.821458421977443
(temperature: float, molar_mass: float)
| 24 | |
| 25 | |
| 26 | def rms_speed_of_molecule(temperature: float, molar_mass: float) -> float: |
| 27 | """ |
| 28 | >>> rms_speed_of_molecule(100, 2) |
| 29 | 35.315279554323226 |
| 30 | >>> rms_speed_of_molecule(273, 12) |
| 31 | 23.821458421977443 |
| 32 | """ |
| 33 | if temperature < 0: |
| 34 | raise Exception("Temperature cannot be less than 0 K") |
| 35 | if molar_mass <= 0: |
| 36 | raise Exception("Molar mass cannot be less than or equal to 0 kg/mol") |
| 37 | else: |
| 38 | return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5 |
| 39 | |
| 40 | |
| 41 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected