# Exercises for chapter 2

By: a guest on Jan 12th, 2012  |  syntax: Python  |  size: 0.75 KB  |  hits: 29  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
2. #Exercises: 2.2 - 2.5
3. #Date     : 01/12/2012
4.
5. #Exercise 2.2
6. name = raw_input("Tell me your name.\n")
7. print "Why hello there, " + name + "!"
8.
9. #Exercise 2.3
10. workHours = raw_input("Enter the amount of hours: ")
11. ratePerHours = raw_input("Enter how much do they paay you each hour: ")
12. fltHours = float(workHours)
13. fltRate = float(ratePerHours)
14. totalPay = fltHours * fltRate
15. print "The total payment is " + str(totalPay)
16.
17. #Exercise 2.4
18. width = 17
19. height = 12.0
20.
21. x = width / 2
22. print x
23.
24. y = width / 2.0
25. print y
26.
27. z = height / 3
28. print z
29.
30. a = 1 + 2 * 5
31. print a
32.
33. #Exercise 2.5
34. celsius = float(raw_input("Enter a value in Celsius: "))
35. fahrenheit = str(celsius * 9 / 5 + 32)
36. print "The value in Fahrenheit is " + fahrenheit + " F."