Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main responsibility of the <strong>Book</strong> class in a library system?
The Book class represents a book's details such as title, author, ISBN, and availability status. It manages information about the book itself.
Click to reveal answer
beginner
What attributes would you expect in a Member class?
Typical attributes include member ID, name, contact information, and a list of current loans. It represents a library user who can borrow books.
Click to reveal answer
intermediate
What role does the <strong>Librarian</strong> class play in the system?
The Librarian class handles administrative tasks like managing books, approving loans, and maintaining member records. It acts as a system operator.
Click to reveal answer
intermediate
Explain the purpose of the <strong>Loan</strong> class in the library system.
The Loan class tracks the borrowing of a book by a member, including loan date, due date, and return status. It connects books and members through borrowing activity.
Click to reveal answer
advanced
How do the classes Book, Member, Librarian, and Loan interact in a library system?
Members borrow Books through Loans, which track the borrowing details. Librarians manage Books and Members, approving loans and updating records.
Click to reveal answer
Which class is responsible for storing the due date of a borrowed book?
ALibrarian
BLoan
CMember
DBook
✗ Incorrect
The Loan class tracks borrowing details including the due date.
Who typically approves a book loan in the system?
ALibrarian
BMember
CBook
DLoan
✗ Incorrect
Librarians handle administrative tasks such as approving loans.
Which attribute would NOT belong in the Member class?
AContact information
BList of current loans
CMember ID
DBook title
✗ Incorrect
Book title belongs to the Book class, not Member.
What is the main purpose of the Book class?
ATrack borrowing dates
BManage member contact info
CStore book details
DApprove loans
✗ Incorrect
The Book class stores details like title, author, and ISBN.
Which class connects a Member and a Book in the system?
ALoan
BLibrarian
CMember
DBook
✗ Incorrect
Loan represents the borrowing relationship between Member and Book.
Describe the key attributes and responsibilities of the Book, Member, Librarian, and Loan classes in a library system.
Think about what each class represents and what information it needs to hold.
You got /4 concepts.
Explain how the classes Book, Member, Librarian, and Loan work together to support borrowing books in a library.
Focus on the flow of borrowing from request to return.
You got /4 concepts.
Practice
(1/5)
1. Which class should be responsible for storing information about a book's title, author, and ISBN in a library system?
easy
A. Member
B. Book
C. Librarian
D. Loan
Solution
Step 1: Identify the class representing a book
The class named Book logically holds details about books such as title, author, and ISBN.
Step 2: Confirm other classes' roles
Member is for library users, Librarian manages operations, and Loan tracks borrowing, so they don't store book details.
Final Answer:
Book -> Option B
Quick Check:
Book class stores book info [OK]
Hint: Book class holds book details like title and author [OK]
Common Mistakes:
Confusing Member with Book class
Assigning book details to Loan class
Thinking Librarian stores book info
2. Which of the following is the correct way to define a method named borrowBook inside the Member class in Python?
easy
A. def borrowBook():
B. def borrowBook(book):
C. def borrowBook(self):
D. def borrowBook(self, book):
Solution
Step 1: Understand method definition in Python classes
Instance methods must have self as the first parameter to access object data.
Step 2: Check method parameters for borrowing a book
The method needs the book to borrow, so it should accept a book parameter after self.
Final Answer:
def borrowBook(self, book): -> Option D
Quick Check:
Instance method with self and book param [OK]
Hint: Instance methods always start with self parameter [OK]
Common Mistakes:
Omitting self parameter
Not passing book argument
Defining method without parameters
3. Given the following Python code snippet, what will be the output?
class Loan:
def __init__(self, book, member):
self.book = book
self.member = member
loan = Loan('1984', 'Alice')
print(loan.book, loan.member)
medium
A. 1984 Alice
B. book member
C. Loan object memory address
D. Error: missing parameters
Solution
Step 1: Analyze the Loan class constructor
The constructor __init__ assigns book and member to instance variables.
Step 2: Check the print statement output
Printing loan.book and loan.member outputs the strings '1984' and 'Alice' separated by space.
Final Answer:
1984 Alice -> Option A
Quick Check:
loan.book and loan.member print values [OK]
Hint: Print instance variables to see stored values [OK]
Common Mistakes:
Expecting object memory address output
Confusing variable names with strings
Assuming error due to parameters
4. Identify the error in this Python class design snippet for the Librarian class:
class Librarian:
def __init__(self, name):
self.name = name
def addBook(book):
print(f"Adding {book} to library")
medium
A. Missing self parameter in addBook method
B. Incorrect print statement syntax
C. Constructor missing return statement
D. Class name should be lowercase
Solution
Step 1: Check method parameters in class
Instance methods must include self as the first parameter to access instance data.
Step 2: Verify addBook method signature
addBook lacks self, so it will cause an error when called on an instance.
Final Answer:
Missing self parameter in addBook method -> Option A
Quick Check:
Instance methods need self param [OK]
Hint: Instance methods always start with self parameter [OK]
Common Mistakes:
Thinking print syntax is wrong
Expecting constructor to return value
Believing class names must be lowercase
5. In designing a library system, which class should handle the logic to check if a book is currently loaned out before allowing a member to borrow it?
hard
A. Book
B. Member
C. Loan
D. Librarian
Solution
Step 1: Understand responsibilities of each class
Book stores book info, Member represents users, Loan tracks borrow records, and Librarian manages library operations.
Step 2: Identify who controls borrowing rules
The Loan class should handle checking if a book is currently loaned out before allowing borrowing, as it tracks loan records.
Final Answer:
Loan -> Option C
Quick Check:
Loan class tracks loan status [OK]
Hint: Loan class tracks if a book is loaned out [OK]
Common Mistakes:
Putting borrowing logic inside Book class
Assigning loan status check to Member
Expecting Librarian class to enforce borrowing rules