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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access