Bird
0
0
LLDsystem_design~10 mins

Why library management tests CRUD design in LLD - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new book record in the library system.

LLD
def add_book(book_list, book):
    book_list.[1](book)
    return book_list
Drag options to blanks, or click blank then click option'
Aremove
Bappend
Cpop
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove instead of append
Trying to pop without index
Clearing the whole list accidentally
2fill in blank
medium

Complete the code to find a book by its ID in the library system.

LLD
def find_book(book_list, book_id):
    for book in book_list:
        if book['id'] == [1]:
            return book
    return None
Drag options to blanks, or click blank then click option'
Aid
Bbook
Cbook_list
Dbook_id
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to the whole book object
Using wrong variable names
Comparing to the list instead of ID
3fill in blank
hard

Fix the error in the code to update a book's title by its ID.

LLD
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
Drag options to blanks, or click blank then click option'
Anew_title
Bbook_id
Ctitle
Dbook_list
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning book_id instead of new_title
Using wrong dictionary key
Returning True too early
4fill in blank
hard

Fill both blanks to delete a book by its ID from the list.

LLD
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
Drag options to blanks, or click blank then click option'
Aenumerate
Bbook_id
Crange
Dbook_list
Attempts:
3 left
💡 Hint
Common Mistakes
Using range without indexing
Comparing to wrong variable
Deleting without index
5fill in blank
hard

Fill all three blanks to create a dictionary of book titles and their authors for books published after 2000.

LLD
books_after_2000 = {book['[1]']: book['[2]'] for book in book_list if book['year'] [3] 2000}
Drag options to blanks, or click blank then click option'
Atitle
Bauthor
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'author' as key
Using '<' instead of '>'
Mixing up keys and values