Answer:
Following are the program in the Python Programming Language.
#set dictionary and initialize value
grocery_list ={"name":"Bread", "Cost": 27, "quantity":2}
#print name of the product
print( "Grocery: ",grocery_list['name'])
#print cost of the product
print("Cost: ",grocery_list['Cost'])
#print quantity of the product
print("Quantity",grocery_list['quantity'])
#update the quantity and cost
grocery_list['quantity'] = 3
grocery_list['Cost'] =40
print()#for space
#print name of the product
print( "Grocery: ",grocery_list['name'])
#print cost of the product after update
print("Cost: ",grocery_list['Cost'])
#print quantity of the product after update
print("Quantity",grocery_list['quantity'])
Output:
Grocery: Bread
Cost: 27
Quantity 2
Product: Bread
Cost: 40
Quantity 3
Step-by-step explanation:
Here, we define the dictionary type variable "grocery_list" and initialize values in it.
- Then, print the name of the grocery.
- Then, print the cost of the following product.
- Then, print quantity of the grocery.
- Then, we update the quantity and cost.
Finally, we again print the following thing after the update.