Programming Examples
Python program to store the product information in dictionary
WAP that repeatedly asks the user to enter product names and prices. Store all of them in a dictionary whose keys are product names and values are prices. And also write a code to search an item from the dictionary.
Output/ Explanation:
Enter name of product : pen
Enter the price of product : 45
Want to add more items (Y/N) : y
Enter name of product : notebook
Enter the price of product : 40
Want to add more items (Y/N) : y
Enter name of product : pencil
Enter the price of product : 10
Want to add more items (Y/N) : n
{'pen': 45, 'notebook': 40, 'pencil': 10}
Enter the product you want to search : notebook
Product found and the price of product notebook is 40