Learn Range in python :python tutuor


SUBMITTED BY: Guest

DATE: Dec. 15, 2013, 8:34 a.m.

FORMAT: Python

SIZE: 515 Bytes

HITS: 722

  1. # range
  2. # 2.x : list
  3. # 3.x : object of type range
  4. # iterable:
  5. # gives values one after another
  6. # at some points, says thats the end
  7. # - keep all values ready; give one when asked for
  8. # - make them when asked for
  9. print (range(5))
  10. print (list(range(5))) # 0 to 5; 5 not inclusive
  11. print (list(range(5, 10))) # 5 6 7 8 9
  12. print (list(range(5, 20, 3))) # 5 8 11 14 17
  13. # range(final) # init = 0, step = 1
  14. # range(init, final)
  15. # range(init, final, step)

comments powered by Disqus