0% found this document useful (0 votes)
9 views

Assignment 1 (1)

Uploaded by

k.birkhanym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Assignment 1 (1)

Uploaded by

k.birkhanym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 1

Advanced Python Programming Assignment

Instructions:

This assignment will test your understanding of multiple Python programming concepts
combined into a single cohesive application. Write a program to solve the problem
below. Include detailed comments explaining each step and your logic.

Problem Statement

You are tasked with creating a "Library Management System" to help a librarian track
and manage books.

Functional Requirements:

1. Book Records

o Start by creating a list of dictionaries where each dictionary represents a


book.

o Each book should have the following attributes:

§ title (string)

§ author (string)

§ year (integer)

§ copies_available (integer)

2. User Input & Menu Options


Create a menu system with the following options:

o Add a Book:

§ Take the title, author, year, and number of copies from the user.

§ Add the book to the list.

§ Ensure that titles are unique. If a title already exists, update the
number of available copies instead.

o Search for a Book:

§ Allow the user to search for a book by title.

§ Display the details of the book if found (use string formatting for
neat output).
§ If the book isn’t found, display “The book was not found”.

o Borrow a Book:

§ Take the book title as input.

§ Check if the book exists and has copies available:

§ If available, decrement the number of copies and display a


success message.

§ If unavailable, display an error message.

o Return a Book:

§ Take the book title as input.

§ Check if the book exists. If it does, increment the number of


available copies. Otherwise, display an error message.

o View All Books:

§ Display all books in a tabular format (use f-strings and string


methods for alignment).

§ Example:

Title Author Year Copies

------------------------------------------------

The Alchemist Paulo Coelho 1988 5

To Kill a Mockingbird Harper Lee 1960 3

o Exit:

§ Exit the program.

3. Validation

o Ensure inputs are valid (e.g., year must be a positive integer, copies must
be non-negative).

o If invalid input is detected, prompt the user again until correct data is
entered.

4. Additional Functionalities

o Use arithmetic operators to calculate total books borrowed (initial


copies - current copies).
o Implement decision structures to handle di]erent cases for menu
options and user inputs.

o Use repetition structures (loops) for the menu and to re-prompt the user
for invalid inputs.

o Leverage string methods to handle case-insensitive searches and format


outputs.

You might also like