Python Program
Python Program
def display_menu():
def display_inventory():
f=open("mobilestoresys.txt","rb")
print("\nInventory List:")
a=pickle.load(f)
print(a)
def add_mobile():
t=()
f=open("mobilestoresys.txt","ab")
print("\nAdd New Mobile Phone")
brand = input("Enter mobile brand: ")
model = input("Enter mobile model: ")
price = input("Enter mobile price: ")
quantity = int(input("Enter quantity: "))
t=({"brand": brand, "model": model, "price": price, "quantity": quantity})
pickle.dump(t,f)
def update_mobile_quantity():
f=open("mobilestoresys.txt","rb")
for i in f:
if i['brand'] == brand and i['model'] == model:
i['quantity'] = int(new_quantity)
def main():
while True:
display_menu()
choice = input("Enter your choice (1/2/3/4): ")
if choice == '1':
add_mobile()
elif choice == '2':
display_inventory()
elif choice == '3':
update_mobile_quantity()
elif choice=='4':
delete_mobile()
main()