Random

Temperature converter

# Temperature converter
# Description
# Write two functions that will convert temperatures back and forth from the Celsius and Fahrenheit temperature scales. The formulas for making the conversion are as follows:
  # Tc=(5/9)*(Tf-32)
  # Tf=(9/5)*Tc+32
# where Tc is the Celsius temperature and Tf is the Fahrenheit temperature. More information and further descriptions of how to do the conversion can be found at this NASA Webpage. If you finish this assignment quickly, add a function to calculate the wind chill.
# Input
# Your program should ask the user to input a temperature and then which conversion they would like to perform.
# Sample session
# Temperature converter
# Enter a temperature: 20
# Convert to (F)ahrenheit or (C)elsius? F
 # 20 C = 68 F

temp = raw_input('Enter Temperature:')
choice = raw_input('Convert to (F)ahrenheit or (C)elsius ?')
if choice == 'F':
   print   temp + ' C = ' + str((9*int(temp)/5)+32) + ' F'
else:
   print  temp+ ' F = ' + str((int(temp)-32)*5/9) + ' C'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s