def Taxes(income, MARS, tbrk_base,
          rate1, rate2, rate3, rate4, rate5, rate6, rate7, rate8,
          tbrk1, tbrk2, tbrk3, tbrk4, tbrk5, tbrk6, tbrk7):
    """
    Taxes function returns tax amount given the progressive tax rate
    schedule specified by the rate* and (upper) tbrk* parameters and
    given income, filing status (MARS), and tax bracket base (tbrk_base).
    """
    if tbrk_base > 0.:
        brk1 = max(tbrk1[MARS - 1] - tbrk_base, 0.)
        brk2 = max(tbrk2[MARS - 1] - tbrk_base, 0.)
        brk3 = max(tbrk3[MARS - 1] - tbrk_base, 0.)
        brk4 = max(tbrk4[MARS - 1] - tbrk_base, 0.)
        brk5 = max(tbrk5[MARS - 1] - tbrk_base, 0.)
        brk6 = max(tbrk6[MARS - 1] - tbrk_base, 0.)
        brk7 = max(tbrk7[MARS - 1] - tbrk_base, 0.)
    else:
        brk1 = tbrk1[MARS - 1]
        brk2 = tbrk2[MARS - 1]
        brk3 = tbrk3[MARS - 1]
        brk4 = tbrk4[MARS - 1]
        brk5 = tbrk5[MARS - 1]
        brk6 = tbrk6[MARS - 1]
        brk7 = tbrk7[MARS - 1]
    return (rate1 * min(income, brk1) +
            rate2 * min(brk2 - brk1, max(0., income - brk1)) +
            rate3 * min(brk3 - brk2, max(0., income - brk2)) +
            rate4 * min(brk4 - brk3, max(0., income - brk3)) +
            rate5 * min(brk5 - brk4, max(0., income - brk4)) +
            rate6 * min(brk6 - brk5, max(0., income - brk5)) +
            rate7 * min(brk7 - brk6, max(0., income - brk6)) +
            rate8 * max(0., income - brk7))