Python Forum
Temp Converter with Kelvin
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temp Converter with Kelvin
#7
I'm not exactly understanding your conversion methods, but this is how I would do it:
print("K for kelvin, C for Celsius, F for Fahrenheit ")

option = None
while not option in ['c', 'f', 'k']:
    option = input("Enter Selection: ").lower()


temp = float(input("Input Temperature in {}: ".format(option.upper())))
conversions = dict(kelvin=None, celsius=None, fahrenheit=None)

if option == 'k':
    conversions.update([('celsius', temp-273.16), ('fahrenheit', (temp+273.16)*(9/5)+32), ('kelvin', temp)])
elif option == 'c':
    conversions.update([('celsius', temp), ('fahrenheit', temp*(9/5)+32), ('kelvin', temp+273.16)])
elif option == 'f':
    conversions.update([('celsius', (temp-32)*(5/9)), ('fahrenheit', temp), ('kelvin', (temp-32)*(5/9)+273.16)])

print(conversions)
Reply


Messages In This Thread
Temp Converter with Kelvin - by vader33 - Oct-01-2016, 02:32 PM
RE: Temp Converter with Kelvin - by ichabod801 - Oct-01-2016, 02:41 PM
RE: Temp Converter with Kelvin - by vader33 - Oct-01-2016, 10:24 PM
RE: Temp Converter with Kelvin - by ichabod801 - Oct-01-2016, 02:46 PM
RE: Temp Converter with Kelvin - by ichabod801 - Oct-01-2016, 11:35 PM
RE: Temp Converter with Kelvin - by vader33 - Oct-02-2016, 05:16 AM
RE: Temp Converter with Kelvin - by Vexis - Oct-02-2016, 03:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My first temperature converter TheLowEndTheory 7 3,662 Oct-18-2020, 04:39 PM
Last Post: buran
  Temperature converter Help (ASAP) Edison_Weng 1 2,913 Apr-16-2018, 01:55 PM
Last Post: stranac
  Using a range and for loop - temp converter rattlerskin 5 15,962 Jan-20-2017, 09:15 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020