【发布时间】:2018-06-09 14:07:37
【问题描述】:
我需要设置一个仅管理 3 种产品库存的程序(选择 1 只是打印关于所有库存的数量、价格或两者的事实,选择 2 是打印关于特定产品的信息,我还没有得到到第三部分了)。
问题:一旦我使用input 输入1 和3 之间的操作,没有其他输出,但没有错误。
products = [['pen', 'pencil','notebook'], [10,20,30],[1, .5, 2]]
total_number_items = products[1][0] + products [1][1] + products[1][2]
min_num = min(products[1])
max_num = max(products[1])
print('1.Generate overall statistics for the entire inventory (total number
of items, average price per item, the minimum number of items among the
products and the maximum number of items among the products')
print('2.Retrieve information (quantity or price) for a given product')
print('3.Update information (quantity or price) for a given product')
choice = input('Select an operation by entering its number: ')
if choice == 1:
print ('Total number of items in inventory is: ',total_number_items)
print ('The minimum number of items among the products is: ', min_num)
print ('The maximum number of items among the products is: ', max_num)
if choice == 2:
inquiry = input('Which product would you like information about? ')
if inquiry == 'pen' or 'Pen' or 'PEN':
inquiry2 = input('Would you like quanity, price, or both? ')
if inquiry2 == 'Quantity' or 'quantity' or 'QUANTITY':
print('Quantity of pens is', products[1][1])
if inquiry2 == 'price' or 'Price' or 'PRICE':
print ('Price of pens is', products[2][1])
if inquiry2 == 'both' or 'Both' or 'BOTH':
print ('Quantity of pens is', products[1][1], 'Price of
pens is', products[2][1])
if inquiry == 'pencil' or 'Pencil' or 'PENCIL':
inquiry2 = input('Would you like quanity, price, or both? ')
if inquiry2 == 'Quantity' or 'quantity' or 'QUANTITY':
print('Quantity of pencils is', products[1][1])
if inquiry2 == 'price' or 'Price' or 'PRICE':
print ('Price of pencils is', products[2][1])
if inquiry2 == 'both' or 'Both' or 'BOTH':
print ('Quantity of pencils is', products[1][1], 'Price of pencils is', products[2][1])
if inquiry == 'notebook' or 'Notebook' or 'NOTEBOOK':
inquiry2 = input('Would you like quanity, price, or both? ')
if inquiry2 == 'Quantity' or 'quantity' or 'QUANTITY':
print('Quantity of notebooks is', products[1][1])
if inquiry2 == 'price' or 'Price' or 'PRICE':
print ('Price of notebooks is', products[2][1])
if inquiry2 == 'both' or 'Both' or 'BOTH':
print ('Quantity of notebooks is', products[1][1], 'Price of notebooks is', products[2][1])
【问题讨论】:
标签: python python-3.x