Support Forums

Full Version: Kelvin to Fahrenheit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My first python script that I wrote entirely on my own. Celsius to Fahrenheit, and Fahrenheit to Celsius have been done a billion times, so I tried to be a bit more creative.

Code:
print "Kelvin to Fahrenheit Converter by Bradley\n\n"
Kelvin = float(raw_input("Enter Kelvin:  "))
Celsius = Kelvin - 273.15
Fahrenheit = Celsius * 1.8 + 32
print
print Fahrenheit
raw_input("")

So, the sun is roughly 5,000 degrees kelvin. Exactly 8.540.6 degrees Fahrenheit.
The average temperature where I live right now is around ~303 Kelvin.

I checked the program with an online converter and it was exact.
Nice for your first code, some minor adjustments can be made though. First,
Code:
print "Kelvin to Fahrenheit Converter by Bradley"
print
print
==
Code:
print "Kelvin to Fahrenheit Converter by Bradley\n\n"
All the empty prints can be substituted with a \n.
Next:
Code:
Kelvin = int(raw_input("Enter Kelvin:  "))
It is best to use floats rather than ints for better accuracy:
Code:
Kelvin = float(raw_input("Enter Kelvin:  "))
Thanks, I'll make note Smile
Looks nice, you should make it 273.15 for more accuracy.
(05-30-2010, 10:13 AM)alfonzo1955 Wrote: [ -> ]Looks nice, you should make it 273.15 for more accuracy.

Thanks. Added Smile