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

Function celsius_to_rankine

conversions/temperature_conversions.py:56–77  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54
55
56def 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
80def fahrenheit_to_celsius(fahrenheit: float, ndigits: int = 2) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected