0% found this document useful (0 votes)
4 views2 pages

Book Management System in Python

The document contains a Python program that manages a book collection with functionalities to add, remove, and display books. Users can input book names and prices, and the program provides feedback on operations like adding or deleting books. It also handles cases where the book list is empty or when trying to remove a book from an empty list.

Uploaded by

BHAVISH MEHTA
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)
4 views2 pages

Book Management System in Python

The document contains a Python program that manages a book collection with functionalities to add, remove, and display books. Users can input book names and prices, and the program provides feedback on operations like adding or deleting books. It also handles cases where the book list is empty or when trying to remove a book from an empty list.

Uploaded by

BHAVISH MEHTA
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

​SOURCE CODE​

​def addbook(book):​
​bk = input("enter the book name:")​
​price = int(input("enter price:"))​
​[Link]([bk, price])​
​print(message[1])​

​def removebook(book):​
​if book == []:​
​print(message[3])​
​else:​
​item = [Link]()​
​print(item, message[2])​

​def displaybooks(book):​
​if book == []:​
​print(message[0])​
​else:​
​top = len(book) - 1​
​for i in range(top, -1, -1):​
​print(book[i])​

​ ook = []​
b
​message = ['stack empty', 'book added', 'book deleted', 'underflow']​

​ ns = 'y'​
a
​while ans == 'y':​
​print("[Link]")​
​print("[Link]")​
​print("[Link]")​
​ch = int(input("enter your choice"))​
​if ch == 1:​
​addbook(book)​
​if ch == 2:​
​removebook(book)​
​if ch == 3:​
​displaybooks(book)​
​ans = input("do you want to continue?(y/n)")​
​OUTPUT​

​ .Push​
1
​[Link]​
​[Link]​
​enter your choice 1​
​enter the book name: Python Basics​
​enter price: 450​
​book added​
​do you want to continue?(y/n) y​

​ .Push​
1
​[Link]​
​[Link]​
​enter your choice 1​
​enter the book name: Data Science​
​enter price: 650​
​book added​
​do you want to continue?(y/n) y​

​ .Push​
1
​[Link]​
​[Link]​
​enter your choice 3​
​['Data Science', 650]​
​['Python Basics', 450]​
​do you want to continue?(y/n) y​
​[Link]​
​[Link]​
​[Link]​
​enter your choice 2​
​['Data Science', 650] book deleted​

​ o you want to continue?(y/n) y​


d
​[Link]​
​[Link]​
​[Link]​
​enter your choice 3​
​['Python Basics', 450]​
​do you want to continue?(y/n) y​
​[Link]​
​[Link]​
​[Link]​

​ nter your choice 2​


e
​['Python Basics', 450] book deleted​
​do you want to continue?(y/n) y​
​[Link]​
​[Link]​
​[Link]​
​enter your choice 2​
​underflow​

You might also like