Exercises

Here are some exercises for you to try on your own. Solutions are available at http://pragprog.com/titles/gwpy2/practical-programming.

  1. Variable kingdoms refers to the list [’Bacteria’, ’Protozoa’, ’Chromista’, ’Plantae’, ’Fungi’, ’Animalia’]. Using kingdoms and either slicing or indexing with positive indices, write expressions that produce the following:

    1. The first item of kingdoms
    2. The last item of kingdoms
    3. The list [’Bacteria’, ’Protozoa’, ’Chromista’]
    4. The list [’Chromista’, ’Plantae’, ’Fungi’]
    5. The list [’Fungi’, ’Animalia’]
    6. The empty list
  2. Repeat the previous exercise using negative indices.

  3. Variable appointments refers to the list [’9:00’, ’10:30’, ’14:00’, ’15:00’, ’15:30’]. An appointment is scheduled for 16:30, so ...

Get Practical Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.