Convert a given value from Celsius to Kelvin and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Celsius Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin >>> celsius_to_kelvin(273.354, 3) 546.504 >>> celsius_to_kelvin(273.354, 0)
(celsius: float, ndigits: int = 2)
| 30 | |
| 31 | |
| 32 | def celsius_to_kelvin(celsius: float, ndigits: int = 2) -> float: |
| 33 | """ |
| 34 | Convert a given value from Celsius to Kelvin and round it to 2 decimal places. |
| 35 | Wikipedia reference: https://en.wikipedia.org/wiki/Celsius |
| 36 | Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin |
| 37 | |
| 38 | >>> celsius_to_kelvin(273.354, 3) |
| 39 | 546.504 |
| 40 | >>> celsius_to_kelvin(273.354, 0) |
| 41 | 547.0 |
| 42 | >>> celsius_to_kelvin(0) |
| 43 | 273.15 |
| 44 | >>> celsius_to_kelvin(20.0) |
| 45 | 293.15 |
| 46 | >>> celsius_to_kelvin("40") |
| 47 | 313.15 |
| 48 | >>> celsius_to_kelvin("celsius") |
| 49 | Traceback (most recent call last): |
| 50 | ... |
| 51 | ValueError: could not convert string to float: 'celsius' |
| 52 | """ |
| 53 | return round(float(celsius) + 273.15, ndigits) |
| 54 | |
| 55 | |
| 56 | def celsius_to_rankine(celsius: float, ndigits: int = 2) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected