1.

Write a menu driven program to add or delete stationary items. You should use dictionary to store items and the brand?

Answer»

stationary = { }

while((ch == 1) or (ch == 2))

print(” 1. Add Item \n 2. Delete Item")

ch = int(input(“Enter your choice “))

if(ch==1):

n = int(input(“Enter the number of items to be added in the stationary shop”))

for i in range(n):

item = input(“Enter an item “)

brand = input(“Enter the brand Name”) 

stationary[item] = brand

print(stationary)

elif(ch == 2):

remitem = input(“Enter the item to be deleted from the shop”)

dict.pop(remitem)

print( stationary)

else:

print(“Invalid options. Type 1 to add items and 2 to remove items “)

ch = int(input(“Enter your choice :”)

Output:

1. Add item

2. Delete Item Enter your choice :1

Enter the number of items to be added in the 

stationary shop : 2

Enter an item : Pen

Enter the brand Name : Trimax

Enter an item : Eraser

Enter the brand Name : Camlin

Pen : Trimax

Eraser : Camlin

Enter your choice : 2

Enter the item to be deleted from the shop : Eraser Pen : Trimax

Enter your choice : 3

Invalid options. Type 1 to add items an 2 to remove items.



Discussion

No Comment Found