Guest User

P2PU ex1

a guest
May 10th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #P2PU
  2. #Exercises taken from the book http://www.py4inf.com/book_006.pdf
  3. #Lesson
  4. #http://p2pu.org/en/groups/python-programming-101/content/variables-expressionss-and-statements/
  5.  
  6. ##########################################
  7. #Andres Kwan
  8.  
  9. ##########################################
  10. #2.2
  11. x = raw_input("Enter you name: ")
  12. print 'Hola' ,x
  13. # Hola Andres
  14.  
  15. ##########################################
  16. #2.3
  17. inp = raw_input('Enter Hours\n')
  18. hours = float(inp)
  19.  
  20. inp = raw_input('Enter Rate?\n')
  21. rate  = float(inp)
  22.  
  23. pay = hours * rate
  24.  
  25. print 'pay: ' + str(pay) + '\n'
  26. #pay: 96.25
  27. print "pay: %1.2f \n" % pay
  28. #pay: 96.25
  29.  
  30. ##########################################
  31. #2.4
  32. width = 17
  33. height = 12.0
  34.  
  35. #int
  36. print type(width/2)
  37. #<type 'int'>
  38.  
  39. #float
  40. print type(width/2.0)
  41. #<type 'float'>
  42.  
  43. #float
  44. print type(height/3)
  45. #<type 'float'>
  46.  
  47. #int
  48. print type(1 + 2 * 5)
  49. #<type 'int'>
  50.  
  51. ##########################################
  52. #2.5
  53. celcius =float(raw_input('Celsius temperature?\n'))
  54. fahrenheit = celcius * 9.0/5 + 32
  55. print  str(celcius) + ' Celsius are equivalent to ' + str(fahrenheit) + ' Fahrenheit \n'
Advertisement
Add Comment
Please, Sign In to add comment