Exercises
Here are some exercises for you to try on your own. Solutions are available at http://pragprog.com/titles/gwpy2/practical-programming.
-
Write a for loop to print all the values in the celegans_phenotypes list from Slicing Lists, one per line. celegans_phenotypes refers to [’Emb’, ’Him’, ’Unc’, ’Lon’, ’Dpy’, ’Sma’].
-
Write a for loop to print all the values in the half_lives list from Operations on Lists, all on a single line. half_lives refers to [87.74, 24110.0, 6537.0, 14.4, 376000.0].
-
Write a for loop to add 1 to all the values from whales from Storing and Accessing Data in Lists, and store the converted values in a new list called more_whales. The whales list shouldn’t be modified. whales refers to [5, 4, 7, 3, 2, 3, ...
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.