<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 The function, nonPremCost, calculates the annual out-of-pocket dental expense for a single adult excluding the monthly premium given the following assumptions
Step1:  Here, we consider different dental insurance options which are available online for individual and group member plans.
<ASSISTANT_TASK:>
Python Code:
def nonPremCost(maxY, unitCostPrev, rPrev, prevDeduct, costBase, rBase, baseDeduct):
    paidPrev = 0
    paidBase = 0
    
    # first, calculate the preventive services, suppose that 2 units per year
    totalCostPrev = unitCostPrev * 2
    coveredPrev = min(maxY, max(0, totalCostPrev - prevDeduct) * rPrev)
    #print('coveredPrev=', coveredPrev)
    coveredBase = maxY - coveredPrev
    paidPrev = totalCostPrev - coveredPrev;
    #print('paidPrev=', paidPrev)
    
    # second, calculate the basic filling services, suppose that total cost is costBase
    if coveredBase <= 0:
        paidBase = costBase
    else:
        paidBase = costBase - min(coveredBase, rBase*max(0, costBase-baseDeduct))
        
    extraCost = paidPrev + paidBase
    
    return extraCost  
    
Explanation: The function, nonPremCost, calculates the annual out-of-pocket dental expense for a single adult excluding the monthly premium given the following assumptions:
1) The adult receives preventive services (exam and cleanings) twice a year at a constant rate, unitCostPrev. The insurance package have a deductible for the preventive services at prevDeduct and a copayment coverage of rPrev, 50%-100%.
2) We only consider the adult only needs some basic teeth services beside preventive services.
3) The cost of basic teeth services per year is set in a range from 0 to $2000 per year.
4) There is a deductible for the basic services at baseDeduct and the cost beyond the deductible will be paid by the insurance company at the coverage ratio of rBase.
5) The total paid coverage by the insurance company is bounded by the maximum benefit, maxY, which depends on the selection of the dental insurance package ranging from \$500 to \$2000.
6) In the cases when the deductible is shared by preventive services and basic services, we assume that the preventive services will first claim the deductible. The coverage of basic services will be triggered immediately after the preventive services when the latter use up the deductible, which is usually the case.
End of explanation
unitCostPrev = 150 # cost estimate for each teeth cleaning
x = [50*i for i in range(41)] # vector for total base cost
# BlueCare lower $28.93
# nonPremCost(1000, unitCostPrev, 1, 100, costBase, 0.8, 100)
yB1 = [nonPremCost(1000, unitCostPrev, 1, 100, costBase, 0.8, 100) for costBase in x]
yB1t = [i+28.93*12 for i in yB1] # total out-of-pocket (absolute)
yB1a = [i/.7+28.93*12 for i in yB1] # adjusted to pre-tax cost
# BlueCare Higher $ 44.76
# nonPremCost(1000, unitCostPrev, 1, 0, costBase, 0.8, 60)
yB2 = [nonPremCost(1000, unitCostPrev, 1, 0, costBase, 0.8, 60) for costBase in x]
yB2t = [i+44.76*12 for i in yB2]
yB2a = [i/.7+44.76*12 for i in yB2]
# Metlife Option 1 $33.62
# nonPremCost(1000, unitCostPrev, 1, 0, costBase, 0.7, 75)
yM1 = [nonPremCost(1000, unitCostPrev, 1, 0, costBase, 0.7, 75) for costBase in x]
yM1t = [i+33.62*12 for i in yM1]
yM1a = [i/.7+33.62*12 for i in yM1]
# Metlife Option 2 $37.5
# nonPremCost(1500, unitCostPrev, 1, 0, costBase, 0.7, 50)
yM2 = [nonPremCost(1500, unitCostPrev, 1, 0, costBase, 0.7, 50) for costBase in x]
yM2t = [i+37.5*12 for i in yM2]
yM2a = [i/.7+37.5*12 for i in yM2]
# Metlife Option 3 $42.36
# nonPremCost(2000, unitCostPrev, 1, 0, costBase, 0.8, 25)
yM3 = [nonPremCost(2000, unitCostPrev, 1, 0, costBase, 0.8, 25) for costBase in x]
yM3t = [i+42.36*12 for i in yM3]
yM3a = [i/.7+42.36*12 for i in yM3]
# Guardian Option 1 $ 37.07
# nonPremCost(1000, unitCostPrev, 1, 50, costBase, 0.7, 0)
yG1 = [nonPremCost(1000, unitCostPrev, 1, 50, costBase, 0.7, 0) for costBase in x]
yG1t = [i+37.07*12 for i in yG1]
yG1a = [i/.7+37.07*12 for i in yG1]
# Guardian Option 2 $ 25.50
# nonPremCost(500, unitCostPrev, 0.8, 50, costBase, 0.5, 0)
yG2 = [nonPremCost(500, unitCostPrev, 0.8, 50, costBase, 0.5, 0) for costBase in x]
yG2t = [i+25.50*12 for i in yG2]
yG2a = [i/.7+25.50*12 for i in yG2]
# Metlife Option 4 $37.5
# nonPremCost(1500, unitCostPrev, 1, 0, costBase, 0.8, 50)
yMg = [nonPremCost(1500, unitCostPrev, 1, 0, costBase, 0.8, 50) for costBase in x]
yMgt = [i+37.5*12 for i in yMg]
yMga = [i/.7+37.5*12 for i in yMg]
y = [i+2*unitCostPrev for i in x]
plotChoice = 2
if plotChoice == 0:
    plt.plot(x,yB1,'b--',x,yB2,'b^',x,yM1,'r--',x,yM2,'r^',x,yM3,'r*',x,yG1,'g--', x,yG2,'g^', x, yMg, 'ro')
    plt.title('Extra Dental Cost when preventive cost: %s' %(unitCostPrev*2))
    plt.xlabel('Estimate of basic restorative service cost')
    plt.ylabel('Out-of-pocket copayment (w/o annual premium)')
elif plotChoice == 1:
    plt.plot(x,y,'k', x,yB1t,'b--',x,yB2t,'b^',x,yM1t,'r--',x,yM2t,'r^',x,yM3t,'r*',x,yG1t,'g--', x,yG2t,'g^')
    plt.title('Dental Cost in the bill when preventive cost: %s' %(unitCostPrev*2))
    plt.xlabel('Estimate of basic restorative service cost')
    plt.ylabel('Cost in bill (annual premium plus out-of-pocket copayment)')
elif plotChoice == 2:
    plt.plot(x,y,'k',x,yB1a,'b--',x,yB2a,'b^',x,yM1a,'r--',x,yM2a,'r^',x,yM3a,'r*',x,yG1a,'g--', x,yG2a,'g^', x, yMga, 'ro')
    plt.title('Adjusted Pre-Tax Dental Cost when preventive cost: %s' %(unitCostPrev*2))
    plt.xlabel('Estimate of basic restorative service cost')
    plt.ylabel('Adjusted pre-tax dental cost (annual premium plus out-of-pocket copayment)')
else:
    print('no figure generateds')
plt.show()
Explanation: Here, we consider different dental insurance options which are available online for individual and group member plans.
End of explanation
<END_TASK>