Advertisement
Shannon

py4infoex2.4.py

Nov 11th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!C:\Python32
  2. #filename: py4infoex2.4.py
  3.  
  4. width = 17
  5. height = 12.0
  6.  
  7. #For each expressions, write the value and type of the expression
  8.  
  9. print (width/2)
  10. #expected value: 8 (int, since divisor not a float)
  11. #actual value: 8.5 (float division built into Python3.2, eh?)
  12.  
  13. print (width/2.0)
  14. #expected value: 8.5 (float, since divisor is float)
  15. #actual value: 8.5
  16.  
  17. print (height/3)
  18. #expected value: 4.0 (float, since divisor is float)
  19. #actual value: 4.0
  20.  
  21. print (1 + 2 * 5)
  22. #expected value: 11 (int, since constants are ints; order of operations)
  23. #actual value: 11
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement