Convert a given value from Kelvin to Celsius and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin Wikipedia reference: https://en.wikipedia.org/wiki/Celsius >>> kelvin_to_celsius(273.354, 3) 0.204 >>> kelvin_to_celsius(273.354, 0)
(kelvin: float, ndigits: int = 2)
| 168 | |
| 169 | |
| 170 | def kelvin_to_celsius(kelvin: float, ndigits: int = 2) -> float: |
| 171 | """ |
| 172 | Convert a given value from Kelvin to Celsius and round it to 2 decimal places. |
| 173 | Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin |
| 174 | Wikipedia reference: https://en.wikipedia.org/wiki/Celsius |
| 175 | |
| 176 | >>> kelvin_to_celsius(273.354, 3) |
| 177 | 0.204 |
| 178 | >>> kelvin_to_celsius(273.354, 0) |
| 179 | 0.0 |
| 180 | >>> kelvin_to_celsius(273.15) |
| 181 | 0.0 |
| 182 | >>> kelvin_to_celsius(300) |
| 183 | 26.85 |
| 184 | >>> kelvin_to_celsius("315.5") |
| 185 | 42.35 |
| 186 | >>> kelvin_to_celsius("kelvin") |
| 187 | Traceback (most recent call last): |
| 188 | ... |
| 189 | ValueError: could not convert string to float: 'kelvin' |
| 190 | """ |
| 191 | return round(float(kelvin) - 273.15, ndigits) |
| 192 | |
| 193 | |
| 194 | def kelvin_to_fahrenheit(kelvin: float, ndigits: int = 2) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected