Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python: total for the bill

def bill_total(bill, tax_rate):
    sub_total = 0
    taxable_total = 0
    for line_item in bill:
        line_total = line_item["quantity"] * line_item["item_cost"]
        sub_total += line_total
        if line_item["taxable"]:
            taxable_total += line_total

    return sub_total + (taxable_total * tax_rate)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #total #bill
ADD COMMENT
Topic
Name
3+6 =