Skip to content

Instantly share code, notes, and snippets.

@tirkarthi
Created March 10, 2018 07:46
Show Gist options
  • Save tirkarthi/9fd13f920ca40a542e3031ccbe42da9a to your computer and use it in GitHub Desktop.
Save tirkarthi/9fd13f920ca40a542e3031ccbe42da9a to your computer and use it in GitHub Desktop.
A sample bill program
from __future__ import print_function
def calculate_bill_amount(gem_list, price_list, reqd_gems, reqd_quantity):
bill_amount = -1
gem_dict = dict(zip(gem_list, price_list))
order_dict = dict(zip(reqd_gems, reqd_quantity))
for gem in reqd_gems:
if not gem_dict.get(gem):
return bill_amount
for gem in reqd_gems:
bill_amount = bill_amount + gem_dict[gem] * order_dict[gem]
print(bill_amount)
if bill_amount > 30000:
bill_amount = bill_amount * 0.95
return bill_amount
gem_list = ["Emerald", "Ivory", "Jasper", "Ruby", "Garnet"]
price_list = [1760, 2119, 1599, 3920, 3999]
reqd_gems = ["Ivory", "Emerald", "Garnet"]
reqd_quantity = [3, 10, 2]
bill_amount = calculate_bill_amount(gem_list, price_list, reqd_gems, reqd_quantity)
print(bill_amount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment