Python Forum
Temperature converter Help (ASAP) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Temperature converter Help (ASAP) (/thread-9560.html)



Temperature converter Help (ASAP) - Edison_Weng - Apr-16-2018

I am the beginner of python and I encounter some problems that I don't know how to fix it. If anyone could give some feedback to me, I will be very glad for your help.

After I work it and it shows this notification
NameError: name 'Fahrenheit' is not defined
-----------------------------------------------
Write a Python program to convert temperatures to and from Celsius, Fahrenheit.

Hint:

Fahrenheit and centigrade are two temperature scales in use today. The Celsius scale was developed by Swedish astronomer Andres Celsius. Moreover The Fahrenheit scale was developed by the German physicist Daniel Gabriel Fahrenheit. In the centigrade scale, water freezes at 0 degrees and boils at 100 degrees. In the Fahrenheit scale, water freezes at 32 degrees and boils at 212 degrees.
The Celsius to Fahrenheit conversion formula is:
Celsius=5/9×(Fahrenheit−32)
Celsius=5/9×(Fahrenheit−32)
-----------------------------------------------

a= int(input("Input the temperature you?:"))
b= input("Is the temperature in Fahrenheit or Celsius scales?:")
if (b == Fahrenheit):
    print("The temperature in Fahrenheit is:", c= (a * 1.8) + 32)
else:
    print("The temperature in Celsius is:", c= (a - 32) / 1.8)



RE: Temperature converter Help (ASAP) - stranac - Apr-16-2018

Fahrenheit is the name of a variable. 'Fahrenheit' is a string. You need to use the latter in your if statement.