Computer Science, asked by kummethajeevanajyoth, 1 day ago

Note : You need to press A store has different categories of products in stock shown below. Item Number= [101, 102, 103, 104] Item Name= [Milk, Cheese, GK101.60 , Bread] Price= [42, 50, 500, 40] Stock= [10, 20, 15, 16] 4389 When user give input with 2 values as - 1. Item number for item which user wish to buy.​

Answers

Answered by poojan
52

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

Learn more:

Write a statement to add a Key: Value Pair of 7:49 to dictionary  D={1:1,3:9,5:25}

https://brainly.in/question/43499112

Your friend and you made a list of topics and both of them voted if they like or dislike the topic. They wrote 0 to denote dislike and 1 to denote like..

brainly.in/question/44681897

Similar questions