Complete the code to create a new book record in the library system.
def add_book(book_list, book): book_list.[1](book) return book_list
To add a new book to the list, we use the append method which adds the item at the end.
Complete the code to find a book by its ID in the library system.
def find_book(book_list, book_id): for book in book_list: if book['id'] == [1]: return book return None
We compare each book's 'id' with the given book_id to find the matching book.
Fix the error in the code to update a book's title by its ID.
def update_book_title(book_list, book_id, new_title): for book in book_list: if book['id'] == book_id: book['title'] = [1] return True return False
The new title should be assigned from the new_title parameter, not any other variable.
Fill both blanks to delete a book by its ID from the list.
def delete_book(book_list, book_id): for i, book in [1](book_list): if book['id'] == [2]: del book_list[i] return True return False
We use enumerate to get both index and book, and compare with book_id to find the book to delete.
Fill all three blanks to create a dictionary of book titles and their authors for books published after 2000.
books_after_2000 = {book['[1]']: book['[2]'] for book in book_list if book['year'] [3] 2000}We want the dictionary keys as title, values as author, and filter books where year is greater than 2000.
