Make the Program User-Friendly

DimaG

This is my solution coded in VS Code:

``````def convert_celsius_to_fahrenheit(temperature_in_celsius: float) -> float:
return (temperature_in_celsius * 1.8) + 32

def convert_fahrenheit_to_celsius(temperature_in_fahrenheit: float) -> float:
return (temperature_in_fahrenheit - 32) * 5 / 9

def execute_main():
degrees_celsius = float(
input("\nPlease enter temperature in celsius to convert to fahrenheit: ")
)
fahrenheit_tempr = convert_celsius_to_fahrenheit(degrees_celsius)
print(
f"The {degrees_celsius:.2f} degrees celsius is "
f"{fahrenheit_tempr:.2f} degrees fahrenheit"
)

degrees_fahrenheit = float(
input("\nPlease enter temperature in fahrenheit to convert to celsius: ")
)
celsius_tempr = convert_fahrenheit_to_celsius(degrees_fahrenheit)
print(
f"The {degrees_fahrenheit:.2f} degrees fahrenheit is "
f"{celsius_tempr:.2f} degrees celsius"
)

if __name__ == "__main__":
execute_main()
``````

John Akpan

Here is my user friendly code

``````def convert_cel_to_far(temp_cel):
temp_far = float(temp_cel) * ( 9 / 5 ) + 32
return round(temp_far, 2)

def convert_far_to_cel (temp_far):
temp_cel = float(temp_far - 32 ) * 5 / 9
return round(temp_cel, 2)

conversion_type = input("what is the conversion type: ? \nEnter 'A' if celcius to fahrenheit\nEnter 'B' if fahrenheit to celcius\n: ")
conversion_type = conversion_type.lower()

if conversion_type == "a":
temp_cel = (input("Enter your temperature in celcius: "))
try:
temp_far = convert_cel_to_far(temp_cel)
print(f"The temperature in celcius {temp_cel} is equivalent to {temp_far} in Farenheit")
except ValueError:
print("Please enter a valid numeric value for the temperature.")

elif conversion_type == "b":
temp_far = (input("Enter your temperature in farenheit: "))
try:
temp_cel = convert_far_to_cel(temp_far)
print(f"The temperature in celcius {temp_far} equivalent to {temp_cel} in Celcius")
except ValueError:
print("Please enter a valid numeric value for the temperature.")
``````

to join the conversation.