Working With Data

Thomas J. Kennedy

Contents:

1 The Problem

In an earlier assignment… I referenced Isaac Asimov and J.R.R. Tolkien with specific note of their grammatical prowess.

Suppose we have a list of tuples in the form…

(Author, Title, Series, # in Series)

where

We will use the following convention for numbering:

We would like to provide the following search and filter options:

  1. Output all books written by a single author

  2. Output all books in a given series, in series order

  3. List all authors in descending order by number of series written

  4. List all authors in descending order by number of books written

  5. Output the zeroth book in a series

  6. Output the top author based on number of books written

1.1 Input

This subsection will describe the input content, format, and overall structure.

Isaac Asimov, Prelude to Foundation, Foundation, -2
Isaac Asimov, Forward the Foundation, Foundation, -1
Isaac Asimov, Foundation, Foundation, 0
Isaac Asimov, Foundation and Empire Foundation, 2
Isaac Asimov, Second, Foundation Foundation, 3
Isaac Asimov, Foundation's Edge, Foundation, 4
Isaac Asimov, Foundation and Earth, Foundation,5 
Frank Herbert, Dune, Dune, 0
Frank Herbert, Dune Messiah, Dune, 1
Frank Herbert, Children of Dune, Dune, 2

Just in case you are wondering… I am a big fan of Isaac Asimov’s Foundation series and Robots series. Dune… is next on that list.

1.2 Output

T.B.W.

2 Your Tasks

You tasks are to implement the following functions…

  1. get_all_books_by_author which takes the list of books and returns an iterable (e.g., list) that contains only the books written by that author.

  2. get_all_books_by_series which takes the list of books and returns an iterable (e.g., list) that contains only the books written by that series.

  3. get_zeroth_book which takes a list og books and a series and returns the zeroth book in that series.

3 Mechanics

You can run the main program with…

python3.11 manage_books.py

The test code can be run with…

python3.11 -m pytest -v tests

4 Files

There are two (2) files in this assignment:

You will be working in manage_books.py. Do not modify the other files.

You can access the starting files on GitHub. You may either clone the starting repository (through Git) or download a zip file.

5 Grading

Your grade will be based on the following criteria…

6 Submitting

You will submit your completed copy of manage_books.py as a file upload through Canvas.

Do not alter any of the other source code files, nor change the module interface.