Convert a given value from Kelvin to Fahrenheit and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit >>> kelvin_to_fahrenheit(273.354, 3) 32.367 >>> kelvin_to_fahrenheit(273
(kelvin: float, ndigits: int = 2)
| 192 | |
| 193 | |
| 194 | def kelvin_to_fahrenheit(kelvin: float, ndigits: int = 2) -> float: |
| 195 | """ |
| 196 | Convert a given value from Kelvin to Fahrenheit and round it to 2 decimal places. |
| 197 | Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin |
| 198 | Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit |
| 199 | |
| 200 | >>> kelvin_to_fahrenheit(273.354, 3) |
| 201 | 32.367 |
| 202 | >>> kelvin_to_fahrenheit(273.354, 0) |
| 203 | 32.0 |
| 204 | >>> kelvin_to_fahrenheit(273.15) |
| 205 | 32.0 |
| 206 | >>> kelvin_to_fahrenheit(300) |
| 207 | 80.33 |
| 208 | >>> kelvin_to_fahrenheit("315.5") |
| 209 | 108.23 |
| 210 | >>> kelvin_to_fahrenheit("kelvin") |
| 211 | Traceback (most recent call last): |
| 212 | ... |
| 213 | ValueError: could not convert string to float: 'kelvin' |
| 214 | """ |
| 215 | return round(((float(kelvin) - 273.15) * 9 / 5) + 32, ndigits) |
| 216 | |
| 217 | |
| 218 | def kelvin_to_rankine(kelvin: float, ndigits: int = 2) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected