convert between different units of temperature def celsiustofahrenheitcelsius float ndigits int 2 float return roundfloatcelsius 9 5 32 ndigits def celsiustokelvincelsius float ndigits int 2 float return roundfloatcelsius 273 15 ndigits def celsiustorankinecelsius float ndigits int 2 float return roundfloatcelsius 9 5 491 67 ndigits def fahrenheittocelsiusfahrenheit float ndigits int 2 float return roundfloatfahrenheit 32 5 9 ndigits def fahrenheittokelvinfahrenheit float ndigits int 2 float return roundfloatfahrenheit 32 5 9 273 15 ndigits def fahrenheittorankinefahrenheit float ndigits int 2 float return roundfloatfahrenheit 459 67 ndigits def kelvintocelsiuskelvin float ndigits int 2 float return roundfloatkelvin 273 15 ndigits def kelvintofahrenheitkelvin float ndigits int 2 float return roundfloatkelvin 273 15 9 5 32 ndigits def kelvintorankinekelvin float ndigits int 2 float return roundfloatkelvin 9 5 ndigits def rankinetocelsiusrankine float ndigits int 2 float return roundfloatrankine 491 67 5 9 ndigits def rankinetofahrenheitrankine float ndigits int 2 float return roundfloatrankine 459 67 ndigits def rankinetokelvinrankine float ndigits int 2 float return roundfloatrankine 5 9 ndigits def reaumurtokelvinreaumur float ndigits int 2 float return roundfloatreaumur 1 25 273 15 ndigits def reaumurtofahrenheitreaumur float ndigits int 2 float return roundfloatreaumur 2 25 32 ndigits def reaumurtocelsiusreaumur float ndigits int 2 float return roundfloatreaumur 1 25 ndigits def reaumurtorankinereaumur float ndigits int 2 float return roundfloatreaumur 2 25 32 459 67 ndigits if name main import doctest doctest testmod convert a given value from celsius to fahrenheit and round it to 2 decimal places wikipedia reference https en wikipedia org wiki celsius wikipedia reference https en wikipedia org wiki fahrenheit celsius_to_fahrenheit 273 354 3 524 037 celsius_to_fahrenheit 273 354 0 524 0 celsius_to_fahrenheit 40 0 40 0 celsius_to_fahrenheit 20 0 4 0 celsius_to_fahrenheit 0 32 0 celsius_to_fahrenheit 20 68 0 celsius_to_fahrenheit 40 104 0 celsius_to_fahrenheit celsius traceback most recent call last valueerror could not convert string to float celsius convert a given value from celsius to kelvin and round it to 2 decimal places wikipedia reference https en wikipedia org wiki celsius wikipedia reference https en wikipedia org wiki kelvin celsius_to_kelvin 273 354 3 546 504 celsius_to_kelvin 273 354 0 547 0 celsius_to_kelvin 0 273 15 celsius_to_kelvin 20 0 293 15 celsius_to_kelvin 40 313 15 celsius_to_kelvin celsius traceback most recent call last valueerror could not convert string to float celsius 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 354 0 984 0 celsius_to_rankine 0 491 67 celsius_to_rankine 20 0 527 67 celsius_to_rankine 40 563 67 celsius_to_rankine celsius traceback most recent call last valueerror could not convert string to float celsius convert a given value from fahrenheit to celsius and round it to 2 decimal places wikipedia reference https en wikipedia org wiki fahrenheit wikipedia reference https en wikipedia org wiki celsius fahrenheit_to_celsius 273 354 3 134 086 fahrenheit_to_celsius 273 354 0 134 0 fahrenheit_to_celsius 0 17 78 fahrenheit_to_celsius 20 0 6 67 fahrenheit_to_celsius 40 0 4 44 fahrenheit_to_celsius 60 15 56 fahrenheit_to_celsius 80 26 67 fahrenheit_to_celsius 100 37 78 fahrenheit_to_celsius fahrenheit traceback most recent call last valueerror could not convert string to float fahrenheit convert a given value from fahrenheit to kelvin and round it to 2 decimal places wikipedia reference https en wikipedia org wiki fahrenheit wikipedia reference https en wikipedia org wiki kelvin fahrenheit_to_kelvin 273 354 3 407 236 fahrenheit_to_kelvin 273 354 0 407 0 fahrenheit_to_kelvin 0 255 37 fahrenheit_to_kelvin 20 0 266 48 fahrenheit_to_kelvin 40 0 277 59 fahrenheit_to_kelvin 60 288 71 fahrenheit_to_kelvin 80 299 82 fahrenheit_to_kelvin 100 310 93 fahrenheit_to_kelvin fahrenheit traceback most recent call last valueerror could not convert string to float fahrenheit 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_rankine 273 354 0 733 0 fahrenheit_to_rankine 0 459 67 fahrenheit_to_rankine 20 0 479 67 fahrenheit_to_rankine 40 0 499 67 fahrenheit_to_rankine 60 519 67 fahrenheit_to_rankine 80 539 67 fahrenheit_to_rankine 100 559 67 fahrenheit_to_rankine fahrenheit traceback most recent call last valueerror could not convert string to float fahrenheit convert a given value from kelvin to celsius and round it to 2 decimal places wikipedia reference https en wikipedia org wiki kelvin wikipedia reference https en wikipedia org wiki celsius kelvin_to_celsius 273 354 3 0 204 kelvin_to_celsius 273 354 0 0 0 kelvin_to_celsius 273 15 0 0 kelvin_to_celsius 300 26 85 kelvin_to_celsius 315 5 42 35 kelvin_to_celsius kelvin traceback most recent call last valueerror could not convert string to float kelvin convert a given value from kelvin to fahrenheit and round it to 2 decimal places wikipedia reference https en wikipedia org wiki kelvin wikipedia reference https en wikipedia org wiki fahrenheit kelvin_to_fahrenheit 273 354 3 32 367 kelvin_to_fahrenheit 273 354 0 32 0 kelvin_to_fahrenheit 273 15 32 0 kelvin_to_fahrenheit 300 80 33 kelvin_to_fahrenheit 315 5 108 23 kelvin_to_fahrenheit kelvin traceback most recent call last valueerror could not convert string to float kelvin convert a given value from kelvin to rankine and round it to 2 decimal places wikipedia reference https en wikipedia org wiki kelvin wikipedia reference https en wikipedia org wiki rankine_scale kelvin_to_rankine 273 354 3 492 037 kelvin_to_rankine 273 354 0 492 0 kelvin_to_rankine 0 0 0 kelvin_to_rankine 20 0 36 0 kelvin_to_rankine 40 72 0 kelvin_to_rankine kelvin traceback most recent call last valueerror could not convert string to float kelvin convert a given value from rankine to celsius and round it to 2 decimal places wikipedia reference https en wikipedia org wiki rankine_scale wikipedia reference https en wikipedia org wiki celsius rankine_to_celsius 273 354 3 121 287 rankine_to_celsius 273 354 0 121 0 rankine_to_celsius 273 15 121 4 rankine_to_celsius 300 106 48 rankine_to_celsius 315 5 97 87 rankine_to_celsius rankine traceback most recent call last valueerror could not convert string to float rankine convert a given value from rankine to fahrenheit and round it to 2 decimal places wikipedia reference https en wikipedia org wiki rankine_scale wikipedia reference https en wikipedia org wiki fahrenheit rankine_to_fahrenheit 273 15 186 52 rankine_to_fahrenheit 300 159 67 rankine_to_fahrenheit 315 5 144 17 rankine_to_fahrenheit rankine traceback most recent call last valueerror could not convert string to float rankine convert a given value from rankine to kelvin and round it to 2 decimal places wikipedia reference https en wikipedia org wiki rankine_scale wikipedia reference https en wikipedia org wiki kelvin rankine_to_kelvin 0 0 0 rankine_to_kelvin 20 0 11 11 rankine_to_kelvin 40 22 22 rankine_to_kelvin rankine traceback most recent call last valueerror could not convert string to float rankine 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 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 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 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
def celsius_to_fahrenheit(celsius: float, ndigits: int = 2) -> float:
    
    return round((float(celsius) * 9 / 5) + 32, ndigits)


def celsius_to_kelvin(celsius: float, ndigits: int = 2) -> float:
    
    return round(float(celsius) + 273.15, ndigits)


def celsius_to_rankine(celsius: float, ndigits: int = 2) -> float:
    
    return round((float(celsius) * 9 / 5) + 491.67, ndigits)


def fahrenheit_to_celsius(fahrenheit: float, ndigits: int = 2) -> float:
    
    return round((float(fahrenheit) - 32) * 5 / 9, ndigits)


def fahrenheit_to_kelvin(fahrenheit: float, ndigits: int = 2) -> float:
    
    return round(((float(fahrenheit) - 32) * 5 / 9) + 273.15, ndigits)


def fahrenheit_to_rankine(fahrenheit: float, ndigits: int = 2) -> float:
    
    return round(float(fahrenheit) + 459.67, ndigits)


def kelvin_to_celsius(kelvin: float, ndigits: int = 2) -> float:
    
    return round(float(kelvin) - 273.15, ndigits)


def kelvin_to_fahrenheit(kelvin: float, ndigits: int = 2) -> float:
    
    return round(((float(kelvin) - 273.15) * 9 / 5) + 32, ndigits)


def kelvin_to_rankine(kelvin: float, ndigits: int = 2) -> float:
    
    return round((float(kelvin) * 9 / 5), ndigits)


def rankine_to_celsius(rankine: float, ndigits: int = 2) -> float:
    
    return round((float(rankine) - 491.67) * 5 / 9, ndigits)


def rankine_to_fahrenheit(rankine: float, ndigits: int = 2) -> float:
    
    return round(float(rankine) - 459.67, ndigits)


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:
    
    return round((float(reaumur) * 1.25 + 273.15), ndigits)


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:
    
    return round((float(reaumur) * 1.25), ndigits)


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

    doctest.testmod()