Write a function which converts temperature values, from Celsius(C) to Fahreinheit(F) and from Fahreinheit(F) to Celsius(C) \


Topic: Write a function which converts temperature values, from Celsius(C) to Fahreinheit(F) and from Fahreinheit(F) to Celsius(C) \

Solution

    #  given the temperature value and its unit
def temp_converter(value, unit):
    if unit =='F' and value in range(32, 212):
        converts = (value - 32) * 5.0/9.0
        return converts
    elif unit =='C' and value in range(0,100):
        converts = (9.0/5.0) * value + 32
        return converts
    else:
        raise ValueError
    
    



List all Python Programs