Write a function to convert the temprature celsius 'c' to fahrenheit 'f' or fahrenheit to celsius


Topic: Write a function to convert the temprature celsius 'c' to fahrenheit 'f' or fahrenheit to celsius

Solution

 def temp_converter(temp,temp_given_in = 'f'):
    # Return the converted temprature
    if temp_given_in.lower() == 'f': # Convert to C
        return (temp - 32) * (5/9)
    else: # Convert to F
        return (temp * 9/5) + 32



List all Python Programs