Exercise 1: Temperature Conversion
Exercise 1: Temperature Conversion
Write a Python program to convert temperatures between Celsius and Fahrenheit. Implement the following functions:
- Function: `celsius_to_fahrenheit(celsius)`
– This function takes a temperature value in Celsius as input and returns the equivalent temperature in Fahrenheit. Use the formula: Fahrenheit = (Celsius * 9/5) + 32.
- Function: `fahrenheit_to_celsius(fahrenheit)`
– This function takes a temperature value in Fahrenheit as input and returns the equivalent temperature in Celsius. Use the formula: Celsius = (Fahrenheit – 32) * 5/9.
In the main part of the program, ask the user to choose whether they want to convert from Celsius to Fahrenheit or from Fahrenheit to Celsius. Based on their choice, ask them to input the temperature value and call the corresponding function to perform the conversion and display the result.