Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago