Computer Science, asked by AbhishekRai4485, 9 months ago

Write a python program to calculate the bill amount to be paid by a customer based on the list of gems and quantity purchased. Any purchase with a total bill amount above rs.30000 is entitled for 5% discount. If any gem required by the customer is not available in the store, then consider total bill amount to be -1.

Answers

Answered by lovingheart
16

Python Program:

gemlist=['Amber', 'Aquamarine', 'Opal', 'Topaz']

pricelist=[4392, 1342, 8734, 6421]

requiredgems=['Amber', 'Opal', 'Topaz']

requiredquantity=[2, 1, 3]

billamount=calculateBillAmount(gemlist, pricelist, requiredgems, requiredquantity)

print(billamount)

def calculateBillAmount(gemlist, pricelist, requiredgems, requireddquantity):

billamount = 0

for cnt in range(0, len(requiredd_gems)):

if (requiredgems[cnt] in gemlist) and requiredquantity[cnt] > 0:

for j in range(0, len(gemlist)):

if gemlist[j] == required_gems[i]:

price = pricelist[j]

break

billamount = billamount + (price) * reqdquantity[i]

billamount_amt = billamount - (5 / 100) * billamount

else:

billamount = -1

break

return bill_amount  

Answered by LoneWolf225
5

Answer:

#PF-Assgn-23

def calculate_bill_amount(gems_list, price_list, reqd_gems,reqd_quantity):

   bill_amount=0

   i=0

   total=0

   leng=len(reqd_gems)

   check =  all(item in gems_list for item in reqd_gems)

   if check is True:

       while(i<leng):

           inty=gems_list.index(reqd_gems[i])

           total=total+ price_list[inty]*reqd_quantity[i]

           bill_amount=total

           i=i+1

       if(bill_amount>30000):

           bill_amount=bill_amount-(bill_amount*5)/100

       else:

           bill_amount=total

   else:

       bill_amount=-1

   return bill_amount

#List of gems available in the store

gems_list=["Emerald","Ivory","Jasper","Ruby","Garnet"]

#Price of gems available in the store. gems_list and price_list have one-to-one correspondence

price_list=[1760,2119,1599,3920,3999]

#List of gems required by the customer

reqd_gems=["Ivory","Emerald","Garnet"]

#Quantity of gems required by the customer. reqd_gems and reqd_quantity have one-to-one correspondence

reqd_quantity=[3,10,12]

bill_amount=calculate_bill_amount(gems_list, price_list, reqd_gems, reqd_quantity)

print(bill_amount)

Explanation:

Similar questions