product={“milk”:50,”sugar”:75,”tea”:40,”maggi”:125,”soya oil”:250,”salt”:66,”aata”:300}
m=[]
t=[]
import datetime
z = datetime.datetime.now()
file = open(‘dmartbill.txt’,’w’)
file.write(” ***| WELCOME IN D-MART |*** \n”)
num=int(input(” HOW MANY ITEM NUMBER = “))
for i in range(num):
item=m.append(input(” Enter item name= “))
file.write(” \n”)
file.write(” ******* D-MART TONK ROAD, JAIPUR *******\n”)
file.write(” ********** ITEM INVOICE DETAILS ******** \n”)
file.write(” | | \n”)
for i in range(len(m)):
if(m[i]==”milk”):
x=product.get(“milk”)
t.append(x)
file.write(” | milk————— ” +str(x)+ “Rs. |\n”)
elif(m[i]==”sugar”):
x = product.get(“sugar”)
t.append(x)
file.write(” | sugar————– “+str(x)+ “Rs. |\n”)
elif (m[i] == “tea”):
x = product.get(“tea”)
t.append(x)
file.write(” | tea—————- “+str(x)+ “Rs. |\n”)
elif (m[i] == “maggi”):
x = product.get(“maggi”)
t.append(x)
file.write(” | maggi————- “+str(x)+ “Rs. |\n”)
elif (m[i] == “soya oil”):
x = product.get(“soya oil”)
t.append(x)
file.write(” | soya oil———- “+str(x)+ “Rs. |\n”)
elif (m[i] == “salt”):
x = product.get(“salt”)
t.append(x)
file.write(” | salt————— “+ str(x)+ “Rs. |\n”)
elif (m[i] == “aata”):
x = product.get(“aata”)
t.append(x)
file.write(” | aata————– “+ str(x)+ “Rs. |\n”)
else:
file.write(“item name is wrong and did not matched \n”)
file.write(“** COMPUTER CAN NOT BE GENERATED FINAL BILL **”)
exit()
sum=0
for i in range(len(t)):
sum=sum+t[i]
file.write(” | ———- |\n”)
dis=int(sum*0.05)
file.write(” | TOTAL AMOUNT = “+ str(sum)+”Rs. |\n”)
file.write(” | 5% Discount = “+ str(dis)+”Rs. |\n”)
file.write(” | FINAL PAY AMOUNT = “+ str(sum-dis)+ “Rs. |\n”)
file.write(” ****************************************\n”)
file.write(” INVOICE DATE:- “+ str(z)+ ” \n”)
file.write(“\n ** THANK YOU FOR CHOOSING D-MART ** “)
file.close()