ds_using_tuple.py 576 B

123456789101112131415
  1. # I would recommend always using parentheses
  2. # to indicate start and end of tuple
  3. # even though parentheses are optional.
  4. # Explicit is better than implicit.
  5. zoo = ('python', 'elephant', 'penguin')
  6. print 'Number of animals in the zoo is', len(zoo)
  7. new_zoo = 'monkey', 'camel', zoo
  8. print 'Number of cages in the new zoo is', len(new_zoo)
  9. print 'All animals in new zoo are', new_zoo
  10. print 'Animals brought from old zoo are', new_zoo[2]
  11. print 'Last animal brought from old zoo is', new_zoo[2][2]
  12. print 'Number of animals in the new zoo is', \
  13. len(new_zoo)-1+len(new_zoo[2])