Let's have a look at how the flow of the project would look like:
def enterProducts():
buyingData = {}
enterDetails = True
while enterDetails:
details = input('Press A to add product and Q to quit: ')
if details == 'A':
product = input('Enter product: ')
quantity = int(input('Enter quantity: '))
buyingData.update({product:quantity})
elif details == 'Q':
enterDetails = False
else:
print('Please select a correct option')
return buyingData
while enterDetails:
else:
def getPrice(product,quantity):
}
subtotal = priceData[product]*quantity
print(product + '₹' + str(priceData[product] + 'x' +
str(quantity) + '=' + str(subtotal)))
return subtotal
def getDiscount(billAmount,membership):
if billAmount >= 1000:
discount = 20
elif membership == 'Silver':
discount = 10
elif membership == 'Bronze':
discount = 5
print(str(discount) + '% off for' + membership + '' +
'membership on total amount: ₹'+str(billAmount))
else:
print('No discount on amount less than ₹1000')
return billAmount
def makeBill(buyingData,membership):
for key, value in buyingData.items():
buyingData = enterProducts()
Output:
Press A to add product and Q to quit: A
Enter product: Bread
Enter quantity: 5
Press A to add product and Q to quit: A
Enter product: Coke
Enter quantity: 7
Press A to add product and Q to quit: A
Enter product: Fish
Enter quantity: 2
Press A to add product and Q to quit: A
Enter product: Egg
Enter quantity: 12
Press A to add product and Q to quit: Q
Enter customer membership: Silver
Bread: ₹20x5=100
Coke: ₹50*7=350
Fish: ₹300*2=600
Egg: ₹10*12=120
10%off for Silver membership on total amount: ₹1170
The discounted amount is ₹1053