From b2117e8b039dd2c2f63095759bb6d4ac9ddce9b3 Mon Sep 17 00:00:00 2001 From: Sabari Ganesh <64348740+SabariGanesh-K@users.noreply.github.com> Date: Wed, 30 Sep 2020 20:28:05 +0530 Subject: [PATCH 1/3] Update temperature_conversions.py Added Reaumur scale unit conversions. --- conversions/temperature_conversions.py | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/conversions/temperature_conversions.py b/conversions/temperature_conversions.py index 43d682a70a2e..be5ba93e7f16 100644 --- a/conversions/temperature_conversions.py +++ b/conversions/temperature_conversions.py @@ -302,6 +302,73 @@ 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__": From 27ffc96932aff6de90054ce72acb993345c7616d Mon Sep 17 00:00:00 2001 From: Sabari Ganesh <64348740+SabariGanesh-K@users.noreply.github.com> Date: Wed, 30 Sep 2020 20:38:58 +0530 Subject: [PATCH 2/3] Update temperature_conversions.py --- conversions/temperature_conversions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/conversions/temperature_conversions.py b/conversions/temperature_conversions.py index be5ba93e7f16..14a981e0bfa9 100644 --- a/conversions/temperature_conversions.py +++ b/conversions/temperature_conversions.py @@ -302,10 +302,12 @@ 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) @@ -319,10 +321,12 @@ def reaumur_to_kelvin(reaumur: float, ndigits: int = 2) -> float: """ 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) @@ -336,10 +340,12 @@ def reaumur_to_fahrenheit(reaumur: float, ndigits: int = 2) -> float: """ 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) @@ -353,10 +359,12 @@ def reaumur_to_celsius(reaumur: float, ndigits: int = 2) -> float: """ 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) @@ -370,6 +378,7 @@ def reaumur_to_rankine(reaumur: float, ndigits: int = 2) -> float: """ return round((float(reaumur) *2.25+32+459.67), ndigits) + if __name__ == "__main__": import doctest From 2ffd0dc3564f3edd0af3390f3052fd637aef3157 Mon Sep 17 00:00:00 2001 From: Sabari Ganesh <64348740+SabariGanesh-K@users.noreply.github.com> Date: Wed, 30 Sep 2020 21:02:29 +0530 Subject: [PATCH 3/3] Update temperature_conversions.py --- conversions/temperature_conversions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/conversions/temperature_conversions.py b/conversions/temperature_conversions.py index 14a981e0bfa9..167c9dc64727 100644 --- a/conversions/temperature_conversions.py +++ b/conversions/temperature_conversions.py @@ -307,7 +307,7 @@ 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) @@ -319,14 +319,14 @@ def reaumur_to_kelvin(reaumur: float, ndigits: int = 2) -> float: ... ValueError: could not convert string to float: 'reaumur' """ - return round((float(reaumur) *1.25 + 273.15), ndigits) + 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) @@ -338,14 +338,14 @@ def reaumur_to_fahrenheit(reaumur: float, ndigits: int = 2) -> float: ... ValueError: could not convert string to float: 'reaumur' """ - return round((float(reaumur) *2.25 + 32), ndigits) + 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) @@ -357,14 +357,14 @@ def reaumur_to_celsius(reaumur: float, ndigits: int = 2) -> float: ... ValueError: could not convert string to float: 'reaumur' """ - return round((float(reaumur) *1.25), ndigits) + 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) @@ -376,7 +376,7 @@ def reaumur_to_rankine(reaumur: float, ndigits: int = 2) -> float: ... ValueError: could not convert string to float: 'reaumur' """ - return round((float(reaumur) *2.25+32+459.67), ndigits) + return round((float(reaumur) * 2.25 + 32 + 459.67), ndigits) if __name__ == "__main__":