Advertisement
lmayo

Exercise 2.5

Dec 28th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Exercise 2.5
  3. # Author: Landon Mayo
  4. # Title: Celsius to Fahrenheit Converter
  5. '''
  6. Exercise 2.5 Write a program which prompts the user for a Celsius temperature, convert the
  7. temperature to Fahrenheit and print out the converted temperature.
  8. '''
  9. #****************************************************
  10. # The conversion formulas between F and C are:  
  11. #                      
  12. # C = (F - 32) * 5/9               
  13. #                      
  14. # F = C * 9/5 + 32             
  15. #****************************************************
  16.  
  17. # getC is the temperature in Celsius (input from user)
  18. # putF converts the getC to float then performs the conversion
  19. # finally we print out the results
  20. def convertC():
  21.     getC = raw_input('Enter Celsius Temperature: ')
  22.     putF = float(getC) * 9/5 + 32
  23.     print float(getC), 'Celsius =' ,float(putF), 'Fahrenheit'
  24.    
  25. convertC()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement