Python Forum
Temp Converter with Kelvin
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temp Converter with Kelvin
#8
(Oct-01-2016, 11:35 PM)ichabod801 Wrote: You calculate the output variables, but you don't actually use them in the output. You output tempFormatted, but that is calculated off of temp, which is the original input. You need to calculate tempFormatted from fahrenTemp or celsiusTemp, and then print that. But not that you need to figure out which two calculated variables to output based on the which variable. You are basically already do that when you are calculating them, so you should probably just output them when you calculate them.

You're exactly right. I see where I went wrong and made the changes. It took a little doing (this is only my 4th class in Intro to Programming lol), and here's what I came up with: 
if which =='F':
    celsiusTemp = (temp - 32) * 5/9
    kelvinTemp = (5/9 * (temp - 32) + 273.15)
    tempFormattedC = format(celsiusTemp, '4.1f')
    tempFormattedK = format(kelvinTemp, '4.1f')
    print('The converted temperature in Kelvin is', tempFormattedK)
    print('The converted temperature in Celsius is', tempFormattedC)
I just followed the same format for conversions with Celsius and Kelvin, and everything works as it should. Thanks for your help!
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,563 Oct-18-2020, 04:39 PM
Last Post: buran
  Temperature converter Help (ASAP) Edison_Weng 1 2,853 Apr-16-2018, 01:55 PM
Last Post: stranac
  Using a range and for loop - temp converter rattlerskin 5 15,806 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