A store has different categories of products in stock as shown below. Item Number=[101, 102, 103, 1047 57 Item Name= [Milk, Cheese, Price= [42, 50, 500, 40] Stock=[10, 20, 15, 16] $3,Mee Bread] When user give input with 2 values as - 1. Item number for item which user wish to buy. 2. Quantity for the item entered above. 4315731162_5 When user enters above input, the 16 de should check the Stock user Calculate 3157311025 1. If quantity is less than stock and item is available display a notification message showing Output Line1- INR price in float with precision1 Output Line2- LEFT i/updated stock for Item after purchase 2. If the quantity in stock is less than quantity entered by user while placing order, then display message: 57311025 Output Line1- NO STOCK Output Line2- LEFT 3. If user enter character as input for item number and quantity or enter item number which is not available then display following message and stop, . Output Line 1- INVALID INPUT
Answers
Answer:
Language used: Python Programming
Program:
#defining lists
ItemNumber= [101, 102, 103, 104]
Item Name= [Milk, Cheese, Ghee, Bread]
Price= [42, 50, 500, 40]
Stock= [10, 20, 15, 16]
#Taking the inputs
itemnum = input()
quantity = input()
#checking if no characters are inputted and if the itemnumber entered is present in the given list or not
if itemnum.isnumeric() and quantity.isnumeric() and (itemnum in ItemNumber):
itemnum=int(itemnum)
quantity=int(quantity)
#taking the index of the itemnumber for further usage
for i in range(len(ItemNumber)):
if itemnum == ItemNumber[i]:
indexx=i
break
#Print the bill, if the asked quantity is available in the stock; update the stock and print the stock left.
if (quantity<=Stock[indexx]):
print("{:.1f} INR".format(quantity*Price[indexx]))
Stock=Stock[indexx]-quantity
print("{0} LEFT".format(Stock[indexx]))
#Print the NO STOCK left message if the quantity asked is greater than the stock available and print the stock in availability.
elif quantity>Stock[indexx]:
print("NO STOCK")
print("{0} LEFT".format(Stock[indexx]))
#When the invalid value is inputted by the user
else:
print("INVALID INPUT")
Explanation:
mark in brainlist