Comprog-Questions
Comprog-Questions
Function: addPC()
Function: viewPC()
Function: buyProduct()
What data structures are you using to store products, customers, and transactions?
o Answer: I use lists of dictionaries:
products list stores dictionaries for each product.
customers list stores dictionaries for each customer.
transactions list stores dictionaries for each transaction.
Why do you use dictionaries?
o Answer: Dictionaries make it easy to organize and store data with key-value pairs (e.g.,
"Code", "Name", etc.), making it efficient to access or update specific information.
How do you ensure that the product stock decreases when a customer buys something?
o Answer: When a purchase is confirmed, the program iterates through the cart items and
subtracts the purchased quantity from the respective product's stock.
What happens if a customer tries to buy more items than available stock?
o Answer: The program displays a message saying "Not enough stock available!" and doesn't
allow the purchase.