Advertisement
Guest User

P@PU Python Task 3 - Variable, expression and statements

a guest
Apr 16th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. # Python for Informatics
  4. # Chapter 2 - Variable, expression and statements
  5. print 'Python for Informatics - Chapter 2: Variable, expression and statements'
  6.  
  7. # Exercise 2.2
  8. print '\n# Exercise 2.2\n'
  9. prompt = raw_input('Enter your name: ')
  10. print 'Hello', prompt
  11.  
  12. # Exercise 2.3
  13. print '\n# Exercise 2.3\n'
  14. hours = float(raw_input('Enter Hours: '))
  15. rate  = float(raw_input('Enter Rate : '))
  16. pay   = round(hours * rate, 2)
  17. print 'Pay:', pay
  18.  
  19. # Exercise 2.4
  20. print '\n# Exercise 2.4\n'
  21. print 'width  = 17'
  22. print 'height = 12.0\n'
  23. print 'width/2   = 8   , integer'
  24. print 'width/2.0 = 8.5 , float'
  25. print 'height/3  = 4.0 , float'
  26. print '1 + 2 * 5 = 11  , integer'
  27.  
  28. # Exercise 2.5
  29. print '\n# Exercise 2.5\n'
  30. celsius = float(raw_input('Temperature in Celsius: '))
  31. fahrenheit = celsius * 1.8 + 32
  32. print round(celsius,1), 'C =', round(fahrenheit,1), 'F'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement