0% found this document useful (0 votes)
9 views

Python Program

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Program

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import pickle

def display_menu():

print("\nMobile Store Management System")


print("1. Add Mobile to Inventory")
print("2. Display Inventory")
print("3. Update Mobile Quantity")
print("4.delete mobile")
print("5. Exit")

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)

print("Mobile added to inventory.")

def update_mobile_quantity():
f=open("mobilestoresys.txt","rb")

print("\nUpdate Mobile Quantity")


brand = input("Enter mobile brand: ")
model = input("Enter mobile model: ")
new_quantity = int(input("Enter new quantity: "))

for i in f:
if i['brand'] == brand and i['model'] == model:
i['quantity'] = int(new_quantity)

print("Mobile quantity updated.")


else:
print("Mobile not found in inventory.")
f.close()
def delete_mobile() :
f=open("mobilestoresys.txt","wb")
print("\nDelete Mobile Phone")
brand = input("Enter mobile brand: ")
model = input("Enter mobile model: ")
for i in f :
if i["brand"]==brand and i["model"]==model:
del (i)
f.close()

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()

elif choice == '5':

print("Exiting the program.")


break
else:
print ( ' Invalid choice Please enter a number between 1 and 5')

main()

You might also like