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

Function fahrenheit_to_rankine

conversions/temperature_conversions.py:140–167  ·  view source on GitHub ↗

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

(fahrenheit: float, ndigits: int = 2)

Source from the content-addressed store, hash-verified

138
139
140def fahrenheit_to_rankine(fahrenheit: float, ndigits: int = 2) -> float:
141 """
142 Convert a given value from Fahrenheit to Rankine and round it to 2 decimal places.
143 Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
144 Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
145
146 >>> fahrenheit_to_rankine(273.354, 3)
147 733.024
148 >>> fahrenheit_to_rankine(273.354, 0)
149 733.0
150 >>> fahrenheit_to_rankine(0)
151 459.67
152 >>> fahrenheit_to_rankine(20.0)
153 479.67
154 >>> fahrenheit_to_rankine(40.0)
155 499.67
156 >>> fahrenheit_to_rankine(60)
157 519.67
158 >>> fahrenheit_to_rankine(80)
159 539.67
160 >>> fahrenheit_to_rankine("100")
161 559.67
162 >>> fahrenheit_to_rankine("fahrenheit")
163 Traceback (most recent call last):
164 ...
165 ValueError: could not convert string to float: 'fahrenheit'
166 """
167 return round(float(fahrenheit) + 459.67, ndigits)
168
169
170def kelvin_to_celsius(kelvin: float, ndigits: int = 2) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected