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:
Sabari Ganesh 2020-10-03 22:02:58 +05:30 committed by GitHub
parent 43f92490fe
commit e9865ae611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,6 +303,82 @@ def rankine_to_kelvin(rankine: float, ndigits: int = 2) -> float:
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__":
import doctest