Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

ASSIGNMENT-5

IP- LAB
NAME: - OMKAR JAYBHAYE
PRN: - 20230802109
BATCH: - A3
AIM- Creating a product database using a dictionary and storing following information
about product p_id, p_name, p_company and p_price.

INTRODUCTION-
 A database is a structured collection of data that is organized and stored in a way that
makes it easy to retrieve, update, and manage information. It acts as a digital storage
for storing and managing data, allowing users to efficiently store, retrieve, delete and
manipulate data for various purposes, such as storing customer information, product
details, or any other type of data.

ALGORITHM-
 Defining a A dictionary is a data structure that stores a collection of key-value pairs.
Each key is unique and used to access its associated value. Dictionaries are flexible,
unordered, and mutable, making them useful for quickly looking up values based on
their keys.
1. product database dictionary and providing a menu interface to perform various
operations on the database (adding, deleting, updating, and displaying products).

2. The program uses a while loop to continuously display the menu and process user
input until the user chooses to exit.

3. Takes input from the user according to the menu defined

3.1 The ‘add_product’ function adds a new product to the database.


3.2 The ‘delete_product’ function deletes a specified product from the database.
3.3 The ‘update_price’ function updates the price of a specified product.
3.4 The ‘show_product_details’ function displays details of a specified product.
3.5 The ‘display_all_products’ function shows a list of all products in the database.
3.6 Exits the program.

4. Prompt to select an option from the menu (1 to 6) and then providing input
accordingly. The program keeps running until the user chooses to exit.
CODE:-
OUTPUT-
Adding new products
Updating the price of a product and viewing its details
Viewing all product details

After deleting a product and exiting the program


PROBLEMS FACED (ERRORS)-
1. When taking input, the code assumes the correct data types for product ID and price. If
a user enters a non-integer for the product ID or a non-float for the price, it may lead
to type error.
2. Datatype mismatch while defining a dictionary.
3. The code uses an infinite `while` loop for the menu. There should be a exit condition
i.e. ‘break’ so the code does not continue infinitely.
4. When trying to access or delete a product, if the specified product ID does not exist in
the dictionary, it will raise a KeyError.
RESULT/CONCLUSION-
Overall, this code is a simple menu-based product management system that allows users to
interact with a product database.

You might also like