mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Update temperature_conversions.py (#2522)
* Update temperature_conversions.py Added Reaumur scale unit conversions. * Update temperature_conversions.py * Update temperature_conversions.py
This commit is contained in:
parent
43f92490fe
commit
e9865ae611
|
@ -303,6 +303,82 @@ def rankine_to_kelvin(rankine: float, ndigits: int = 2) -> float:
|
||||||
return round((float(rankine) * 5 / 9), ndigits)
|
return round((float(rankine) * 5 / 9), ndigits)
|
||||||
|
|
||||||
|
|
||||||
|
def reaumur_to_kelvin(reaumur: float, ndigits: int = 2) -> float:
|
||||||
|
"""
|
||||||
|
Convert a given value from reaumur to Kelvin and round it to 2 decimal places.
|
||||||
|
Reference:- http://www.csgnetwork.com/temp2conv.html
|
||||||
|
|
||||||
|
>>> reaumur_to_kelvin(0)
|
||||||
|
273.15
|
||||||
|
>>> reaumur_to_kelvin(20.0)
|
||||||
|
298.15
|
||||||
|
>>> reaumur_to_kelvin(40)
|
||||||
|
323.15
|
||||||
|
>>> reaumur_to_kelvin("reaumur")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: could not convert string to float: 'reaumur'
|
||||||
|
"""
|
||||||
|
return round((float(reaumur) * 1.25 + 273.15), ndigits)
|
||||||
|
|
||||||
|
|
||||||
|
def reaumur_to_fahrenheit(reaumur: float, ndigits: int = 2) -> float:
|
||||||
|
"""
|
||||||
|
Convert a given value from reaumur to fahrenheit and round it to 2 decimal places.
|
||||||
|
Reference:- http://www.csgnetwork.com/temp2conv.html
|
||||||
|
|
||||||
|
>>> reaumur_to_fahrenheit(0)
|
||||||
|
32.0
|
||||||
|
>>> reaumur_to_fahrenheit(20.0)
|
||||||
|
77.0
|
||||||
|
>>> reaumur_to_fahrenheit(40)
|
||||||
|
122.0
|
||||||
|
>>> reaumur_to_fahrenheit("reaumur")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: could not convert string to float: 'reaumur'
|
||||||
|
"""
|
||||||
|
return round((float(reaumur) * 2.25 + 32), ndigits)
|
||||||
|
|
||||||
|
|
||||||
|
def reaumur_to_celsius(reaumur: float, ndigits: int = 2) -> float:
|
||||||
|
"""
|
||||||
|
Convert a given value from reaumur to celsius and round it to 2 decimal places.
|
||||||
|
Reference:- http://www.csgnetwork.com/temp2conv.html
|
||||||
|
|
||||||
|
>>> reaumur_to_celsius(0)
|
||||||
|
0.0
|
||||||
|
>>> reaumur_to_celsius(20.0)
|
||||||
|
25.0
|
||||||
|
>>> reaumur_to_celsius(40)
|
||||||
|
50.0
|
||||||
|
>>> reaumur_to_celsius("reaumur")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: could not convert string to float: 'reaumur'
|
||||||
|
"""
|
||||||
|
return round((float(reaumur) * 1.25), ndigits)
|
||||||
|
|
||||||
|
|
||||||
|
def reaumur_to_rankine(reaumur: float, ndigits: int = 2) -> float:
|
||||||
|
"""
|
||||||
|
Convert a given value from reaumur to rankine and round it to 2 decimal places.
|
||||||
|
Reference:- http://www.csgnetwork.com/temp2conv.html
|
||||||
|
|
||||||
|
>>> reaumur_to_rankine(0)
|
||||||
|
491.67
|
||||||
|
>>> reaumur_to_rankine(20.0)
|
||||||
|
536.67
|
||||||
|
>>> reaumur_to_rankine(40)
|
||||||
|
581.67
|
||||||
|
>>> reaumur_to_rankine("reaumur")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: could not convert string to float: 'reaumur'
|
||||||
|
"""
|
||||||
|
return round((float(reaumur) * 2.25 + 32 + 459.67), ndigits)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user