MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / kelvin_to_rankine

Function kelvin_to_rankine

conversions/temperature_conversions.py:218–239  ·  view source on GitHub ↗

Convert a given value from Kelvin to Rankine and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale >>> kelvin_to_rankine(273.354, 3) 492.037 >>> kelvin_to_rankine(273.354,

(kelvin: float, ndigits: int = 2)

Source from the content-addressed store, hash-verified

216
217
218def kelvin_to_rankine(kelvin: float, ndigits: int = 2) -> float:
219 """
220 Convert a given value from Kelvin to Rankine and round it to 2 decimal places.
221 Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
222 Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
223
224 >>> kelvin_to_rankine(273.354, 3)
225 492.037
226 >>> kelvin_to_rankine(273.354, 0)
227 492.0
228 >>> kelvin_to_rankine(0)
229 0.0
230 >>> kelvin_to_rankine(20.0)
231 36.0
232 >>> kelvin_to_rankine("40")
233 72.0
234 >>> kelvin_to_rankine("kelvin")
235 Traceback (most recent call last):
236 ...
237 ValueError: could not convert string to float: 'kelvin'
238 """
239 return round((float(kelvin) * 9 / 5), ndigits)
240
241
242def rankine_to_celsius(rankine: float, ndigits: int = 2) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected