Convert a given value from Celsius to Rankine and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Celsius Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale >>> celsius_to_rankine(273.354, 3) 983.707 >>> celsius_to_rankine(273.
(celsius: float, ndigits: int = 2)
| 54 | |
| 55 | |
| 56 | def celsius_to_rankine(celsius: float, ndigits: int = 2) -> float: |
| 57 | """ |
| 58 | Convert a given value from Celsius to Rankine and round it to 2 decimal places. |
| 59 | Wikipedia reference: https://en.wikipedia.org/wiki/Celsius |
| 60 | Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale |
| 61 | |
| 62 | >>> celsius_to_rankine(273.354, 3) |
| 63 | 983.707 |
| 64 | >>> celsius_to_rankine(273.354, 0) |
| 65 | 984.0 |
| 66 | >>> celsius_to_rankine(0) |
| 67 | 491.67 |
| 68 | >>> celsius_to_rankine(20.0) |
| 69 | 527.67 |
| 70 | >>> celsius_to_rankine("40") |
| 71 | 563.67 |
| 72 | >>> celsius_to_rankine("celsius") |
| 73 | Traceback (most recent call last): |
| 74 | ... |
| 75 | ValueError: could not convert string to float: 'celsius' |
| 76 | """ |
| 77 | return round((float(celsius) * 9 / 5) + 491.67, ndigits) |
| 78 | |
| 79 | |
| 80 | def fahrenheit_to_celsius(fahrenheit: float, ndigits: int = 2) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected