Created
March 10, 2018 07:46
-
-
Save tirkarthi/9fd13f920ca40a542e3031ccbe42da9a to your computer and use it in GitHub Desktop.
A sample bill program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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