Skip to content

Instantly share code, notes, and snippets.

@mahababa
Created October 6, 2019 11:31
Show Gist options
  • Save mahababa/ca4152583e4a9f1a23c519df2d8b4485 to your computer and use it in GitHub Desktop.
Save mahababa/ca4152583e4a9f1a23c519df2d8b4485 to your computer and use it in GitHub Desktop.
def print_bill(items, prices, discounts):
new_i = []
new_p = []
total = 0
"""
items1 = [list(map(int, x)) for x in items]
prices1 = [list(map(int, x)) for x in prices]
discounts1 = [list(map(int, x)) for x in discounts]
"""
prices1 = list(map(int, prices))
discounts1 = list(map(int, discounts))
for (a, b, c) in zip(items, prices1, discounts1):
new_pv = (b - ((b * c)/100))
new_i.append(a)
new_p.append(new_pv)
total = total + new_pv
kab = dict(zip(new_i, new_p))
kab_sorted = sorted(kab, key=kab.get, reverse=True)
for r in kab_sorted:
print(r, "%.02f" % kab[r])
print("Total", "%.02f" % total)
n = int(input())
items = []
prices = []
discounts = []
for i in range(n):
line = input()
(item, price, discount) = line.split();
items.append(item)
prices.append(price)
discounts.append(discount)
print_bill(items, prices, discounts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment