Exercises
Here are some exercises for you to try on your own. Solutions are available at http://pragprog.com/titles/gwpy2/practical-programming.
-
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:
- The first item of kingdoms
- The last item of kingdoms
- The list [’Bacteria’, ’Protozoa’, ’Chromista’]
- The list [’Chromista’, ’Plantae’, ’Fungi’]
- The list [’Fungi’, ’Animalia’]
- The empty list
-
Repeat the previous exercise using negative indices.
-
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.