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

Function rankine_to_celsius

conversions/temperature_conversions.py:242–263  ·  view source on GitHub ↗

Convert a given value from Rankine to Celsius and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale Wikipedia reference: https://en.wikipedia.org/wiki/Celsius >>> rankine_to_celsius(273.354, 3) -121.287 >>> rankine_to_celsius(273

(rankine: float, ndigits: int = 2)

Source from the content-addressed store, hash-verified

240
241
242def rankine_to_celsius(rankine: float, ndigits: int = 2) -> float:
243 """
244 Convert a given value from Rankine to Celsius and round it to 2 decimal places.
245 Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
246 Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
247
248 >>> rankine_to_celsius(273.354, 3)
249 -121.287
250 >>> rankine_to_celsius(273.354, 0)
251 -121.0
252 >>> rankine_to_celsius(273.15)
253 -121.4
254 >>> rankine_to_celsius(300)
255 -106.48
256 >>> rankine_to_celsius("315.5")
257 -97.87
258 >>> rankine_to_celsius("rankine")
259 Traceback (most recent call last):
260 ...
261 ValueError: could not convert string to float: 'rankine'
262 """
263 return round((float(rankine) - 491.67) * 5 / 9, ndigits)
264
265
266def rankine_to_fahrenheit(rankine: float, ndigits: int = 2) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected