TKVR

Chris Pine, Learn to Program Chapter 1 - Numbers

Feb 16th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.49 KB | None | 0 0
  1. puts 1+2
  2.  
  3. # floats
  4. puts 1.0 + 2.0
  5. puts 2.0 * 3.0
  6. puts 5.0 - 8.0
  7. puts 9.0 / 2.0
  8.  
  9. # integers
  10. puts 1+2
  11. puts 2*3
  12. puts 5-8
  13. puts 9/2
  14.  
  15. # experiment with puts
  16. puts 5 * (12-8) + -15
  17. puts 98 + (59872 / (13*8)) * -52
  18.  
  19. # how many hours are in a year?
  20. puts 24 * 365
  21.  
  22. # how many minutes are in a decade?
  23. puts (60 * 24) * (365 * 10)
  24.  
  25. # how many seconds old are you?
  26. puts (60 * 60) * 24 * (365 * 24)
  27.  
  28. # If I am 1031 million seconds old, how old am I?
  29. puts 1031000000 / (60 * 60 * 24 * 365)
Add Comment
Please, Sign In to add comment