#python #practice #exercises
unit = input("Is this temperature in Celsius or Fahrenheit (C/F): ")
temp = float(input("Enter the temperature: "))
if unit == "C":
temp = round((9 * temp) / 5 + 32, 1)
print(f"The temperature in Fahrenheit is: {temp}ยฐF")
elif unit == "F":
temp = round((temp - 32) * 5 / 9, 1)
print(f"The temperature in Celsius is: {temp}ยฐC")
else:
print(f"{unit} is an invalid unit of measurement")
Continue this lesson in the app
Install CourseHive on Android or iOS to keep learning while you move.