Question: I wrote a code, can you check if it is correct and write four pytest for it? #income cap marginal tax rate # [0, 10000]

I wrote a code, can you check if it is correct and write four pytest for it? #income cap marginal tax rate 
# [0, 10000] 0.00 (0%) 
# (10000, 40000] 0.12 (12%) 
# (40000, 85000] 0.22 (22%) 
# (85000, 163000] 0.24 (24%) 
# (163000, 200000] 0.32 (32%) 
# (200000, 500000] 0.35 (35%) 
# (500000, 100000000] 0.37 (37%) 
def Tax(income): 
 ''' 
 - Given an income amount as a whole number 
 where 0 <= income <= 100,000,000 , calculate 
 the amount of tax owed according to the tax brackets above. 
 Return the total tax owed. 
 - Example: if income = 70000, then 
 tax owed = 30000 * 0.12 + (income - 40000) * 0.22 
 ''' 
 a=income 
 tax=0 
 if(a>10000): 
 a = a - 10000 
 if(a>30000): 
 tax = tax+30000*0.12 
 elif(a>0): 
 tax = tax+a*0.12 
 a = a - 30000 
 if(a>45000): 
 tax = tax+45000*0.22 
 elif(a>0): 
 tax = tax+a*0.22 
 a = a - 45000 
 if(a>78000): 
 tax = tax+78000*0.24 
 elif(a>0): 
 tax = tax+a*0.24 
 a = a - 78000 
 if(a>37000): 
 tax = tax+45000*0.32 
 elif(a>0): 
 tax = tax+a*0.32 
 a = a - 37000 

 if(a>300000): 
 tax = tax+300000*0.35 
 elif(a>0): 
 tax = tax+a*0.35 
 a = a - 300000 
 if(a>0): 
 tax = tax+a*0.37 
 return tax

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!