items = []
while True:
display = input('Press enter to continue.')
print('================ Supermarket Management System ================')
print('1. View items\n2. Add items for sale\n3. Purchase items\n4. Search items \n5. Edit items\n6. Exit')
choice = input('Enter the number of your choice : ')
if choice == '1' :
print('------------------View Items------------------')
print('The number of items in the inventory are : ',len(items))
while len(items) != 0:
print('Here are all the items available in the supermarket.')
for item in items:
for key, value in item.items():
print(key, ':', value)
break
elif choice == '2' :
print('------------------Add items------------------')
print('To add an item fill in the form')
item = {}
item['name'] = input('Item name : ')
while True:
try:
item['quantity'] = int(input('Item quantity : '))
break
except ValueError:
print('Quantity should only be in digits')
while True:
try:
item['price'] = int(input('Price $ : '))
break
except ValueError:
print('Price should only be in digits')
print('Item has been successfully added.')
items.append(item)
elif choice == '3' :
print('------------------purchase items------------------')
print(items)
purchase_item = input('which item do you want to purchase? Enter name : ')
for item in items:
if purchase_item.lower() == item['name'].lower() :
if item['quantity'] != 0 :
print('Pay ', item['price'] , 'at checkout counter.')
item['quantity'] -= 1
else:
print('item out of stock.')
elif choice == '4' :
print('------------------search items------------------')
find_item = input('Enter the item\'s name to search in inventory : ')
for item in items:
if item['name'].lower() == find_item.lower():
print('The item named ' + find_item + ' is displayed below with its details')
print(item)
else:
print('item not found.')
elif choice == '5' :
print('------------------edit items------------------')
item_name = input('Enter the name of the item that you want to edit : ')
for item in items:
if item_name.lower() == item['name'].lower():
print('Here are the current details of ' + item_name)
print(item)
item['name'] = input('Item name : ')
while True:
try:
item['quantity'] = int(input('Item quantity : '))
break
except ValueError:
print('Quantity should only be in digits')
while True:
try:
item['price'] = int(input('Price $ : '))
break
except ValueError:
print('Price should only be in digits')
print('Item has been successfully updated.')
print(item)
else:
print('Item not found')
elif choice == '6' :
print('------------------exited------------------')
break
else:
print('You entered an invalid option')
没有合适的资源?快使用搜索试试~ 我知道了~
Simple Supermarket Management System in Python
共1个文件
py:1个
0 下载量 106 浏览量
2023-11-03
16:48:22
上传
评论
收藏 1KB ZIP 举报
温馨提示
Simple Supermarket Management System in Python
资源推荐
资源详情
资源评论
收起资源包目录
Simple Supermarket Management System in Python Free Source Code.zip (1个子文件)
Simple Supermarket Management System in Python
index.py 4KB
共 1 条
- 1
资源评论
xiaoshun007~
- 粉丝: 3865
- 资源: 3126
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功