Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to add on to an existing python file by adding extra function to it and receive the following intended results, can someone help

I want to add on to an existing python file by adding extra function to it and receive the following intended results, can someone help me?

I want the python programs to:

Add books

Sort

Update books

Delete books

and search books

Here is better explained:

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

Here is where I have to implement the add-on:

image text in transcribed

Can someone show me what I have to put in it? Thank you

Your implementation should support adding multiple books at once. You prompt the user to enter the details of the books they want to add one at a time. You collect these books into a temporary list, then add them to the list of books already in the database. You should always call save_db ( ) after adding new books Functions - create_book0: takes a title, first and last names of the author, genre, publisher, year, and id as arguments and return a dictionary representing the book. Below is an example book dictionary: \{ 'title': 'The God of Small Things', 'author_fname': 'Arundhati', 'author_lname': 'Roy', 'genre': 'fiction', 'publisher': 'Fourth Estate', 'year' : 1997 \} 1/3 Books Database Part II.md 3/2/2023 - add_books(): takes the next book id as argument, and returns a list of books to be added to the database. The list can contain one or more books, each with a unique id. Assigning ids to books starts with the id passed in as arguments which is then incremented for each additional book. Sorting Display books sorted according to some key. The key will need to be one of the book dictionary keys. The database is a list of dictionaries. You can use the built-in sorted () function to sort a list of dictionaries. You just need to pass it key function, like so: It is perhaps much more convenient and flexible to use the itemgetter function from the operator module, like so: Functions: Books Database Part II.md 3/2/2023 - sort_books(): this function takes a list of books and a key and return the books sorted according to the specified key. Updating a book This is already implemented. Feel free to improve the implementation Deleting a book Delete a single book given the book's id. You should call save_db ( ) after each deletion. Functions - delete_book(): takes a list of books and the id of the book to be deleted, and returns a new list of books with the specified book removed. If the book was not found in the database, return False The searching functionality should support searching books by title and by author's name. If searching by title, the search term can contain multiple words and all books whose title contain any of the words in the search term are returned. If searching by name, the search term contains a single word, and all books whose author's first OR last name matches the search term are returned. Functions - search(): takes a list of books and the search criteria as arguments and return a list of books matching the search criteria. Example: search(books, 'name', 'roy') The God of Small Things Author: Arundhati, Roy Genre: fiction Publisher: Fourth Estate Year: 1997 ID: 1 The Folded Earth Author: Anuradha, Roy Genre: mystery Publisher: Free Press Year: 2011 ID: 5 Complete perform_action() 1. Implement the remaining actions in your perform_action() functions. That is, implement adding books, deleting a book, sorting books, and (optionally) searching for books give a search criteria book database part 1 test python copy-py - Book Database part 2 Z book database part 1 test python copy.py x Database part 2> book database part 1 test python copy,py > perlorm_action

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions