Generation

generate functionThu, 04 May 2023

convert Fahrenheit to Celcius and back, inches to feet and back, and Kg to Lbs and back

def convert(amount, from_unit, to_unit): from_to = { 'fahrenheit': { 'celcius': (amount - 32) * 5/9, 'kelvin': (amount + 459.67) * 5/9 }, 'celcius': { 'fahrenheit': amount * 9/5 + 32, 'kelvin': amount + 273.15 }, 'kelvin': { 'celcius': amount - 273.15, 'fahrenheit': amount * 9/5 - 459.67 }, 'inches': { 'feet': amount * 0.0833333, 'meters': amount * 0.0254 }, 'feet': { 'inches': amount * 12, 'meters': amount * 0.3048 }, 'meters': { 'inches': amount * 39.3701, 'feet': amount * 3.28084 }, 'pounds': {

Questions about programming?Chat with your personal AI assistant