Advertisement
ansakoy

P2PU - Python - Task1

Jun 23rd, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. #Going gradually through P2PU Python course.
  2. #Variables, Expressions and Statements
  3. #Exercise 2.2
  4. name_prompt = raw_input('Enter your name: ')
  5. print 'Hello ' + name_prompt
  6.  
  7. #Exercise 2.3
  8. hours = raw_input("Enter hours: ")
  9. rate = raw_input("Enter rate: ")
  10. pay = (float(hours))*(float(rate))
  11. print pay
  12.  
  13. #Exercise 2.4
  14. width = 17
  15. height = 12.0
  16. first = width/2
  17. #I presume this will result in integer and it will be 8. Checking:
  18. type(first)
  19. secnd = width/2.0
  20. #My guess: result will be 8.5 and type will be float
  21. type(secnd)
  22. third = height/3
  23. #Oops. I don't know. I presume it will be 4 or 4.0, but what type will it be?
  24. #Checked. Type is float
  25. type(third)
  26. fourth = 1 + 2 * 5
  27. # it'll be 11, type int
  28. type(fourth)
  29.  
  30. #Exercise 2.5
  31. #Convert Celsius to Fahrenheit
  32. c = raw_input('Enter temperature in Celsius: ')
  33. f = int(c) * 1.8 + 32
  34. print str(c) + " Celsius is " + str(f) + " Fahrenheit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement