Write a python program that implements a “Fahrenheit to
Celsius converter”. Upon program execution, the user is prompted to enter a
temperature in Fahrenheit and the program will output the corresponding temperature in
Celsius. The formula to convert a temperature given in Fahrenheit (F) to a
temperature in Celsius (C) is C = (F - 32)/1.8. Your solution should make use of floating
point (non-integer) values to obtain full marks. If you are not able to work with floating
point numbers, then provide an implementation with integer values (in this case, you can
use the following formula: C = (F - 32)/2. A solution that works only with integer values
will result in a decrease of marks but part marks will be provided.
while True:
try:
F_temp=float(input('Enter a temperature in Fahrenheit: '))
break
except:
print('You can only enter a numbers.')
C_temp = (F_temp - 32)/1.8
print('Temperature in Celsius is: {:.2f}'.format(C_temp))
Comments
Leave a comment