Python Programming Assessment 8
Community Library Management System (100 Marks)
Instructions:
• Write a complete Python program.
• Use functions throughout your program.
• Use lists where appropriate.
• Apply validation and error handling.
• Screenshots of test runs are not required.
Scenario
A small community library wants a Python system to manage book borrowing statistics and
member activity.
Question 1: Book Borrowing Data Capture (15 Marks)
Create a function called:
def capture_books(book_titles, borrow_counts):
The function must:
• Allow the librarian to enter information for 8 books.
• Ask the user to enter:
o Book title
o Number of times the book was borrowed this month
Validation rules:
• The title may not be empty.
• Borrow count must be numeric.
• Borrow count must be between 0 and 500.
Store the information in two parallel lists:
• book_titles
• borrow_counts
Question 2: Display Library Records (10 Marks)
Create a function called:
def display_books(book_titles, borrow_counts):
Display all books in the format:
Book: Python Basics Times Borrowed: 45
Book: Space Adventures Times Borrowed: 18
Question 3: Borrowing Analysis (10 Marks)
Create a function called:
def borrowing_analysis(book_titles, borrow_counts):
The function must display:
• Total number of borrows
• Average borrow count
• Most borrowed book
• Least borrowed book
Example:
Total Borrows: 240
Average Borrows: 30
Most Borrowed: Python Basics - 56
Least Borrowed: History Today - 4
Question 4: Popularity Categories (20 Marks)
Create a function called:
def popularity_level(count):
The function must return:
Borrow Count Category
100 or more Bestseller
50–99 Popular
20–49 Moderate
Below 20 Low Demand
Display each book with its category:
Python Basics - 120 - Bestseller
History Today - 14 - Low Demand
Also display the number of books in each category.
Question 5: Search Feature (10 Marks)
Create a function called:
def search_book(book_titles, borrow_counts):
The function must:
• Ask the user to enter a book title.
• Search for the title in the list.
If found:
• Display:
o Book title
o Borrow count
o Popularity category
If not found:
• Display:
Book not found
Question 6: String Manipulation (15 Marks)
Create a function called:
def title_processing(book_titles):
For each book title, display:
• Number of words in the title
• Number of vowels in the title
• The title written in uppercase
Example:
Python Basics
Words: 2
Vowels: 3
Uppercase: PYTHON BASICS
Question 7: Menu-Driven System (20 Marks)
Create a menu-driven program that displays the following menu repeatedly until the user
exits:
1. Capture Book Data
2. Display All Books
3. Borrowing Analysis
4. Display Popularity Categories
5. Search for a Book
6. Process Book Titles
7. Exit
Requirements:
• Each option must call a separate function.
• The program must continue running until the user selects Exit.
• Invalid menu options must display an error message.