Question

DESCRIPTION Using For.. loop, Write a program to fetch the name, salary and the state of 5 employees. Calculate the federal t

Please do this in Python 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

'''
Python version : 3.6
Python program to input the name, salary and state of 5 employees and calculate
the federal and state tax and net salary for all the 5 employees
'''

# list to store the name, salary, state , federal_tax and state_tax of employees
name_list = []
salary_list = []
state_list = []
federal_tax_list = []
state_tax_list = []

# loop 5 times to collect information of 5 employees from user
for i in range(5):
   print('Enter the details for Employee-%d'%(i+1))
   name = input('Name: ')
   salary = float(input('Salary: '))
   state = input('State: ')
  
   # add the name, state and salary to the list
   name_list.append(name)
   salary_list.append(salary)
   state_list.append(state)
  
   # calculate federal tax and add it to the list
   if salary > 100000:
       federal_tax = salary*0.2
   else:
       federal_tax = salary*.15
      
   federal_tax_list.append(federal_tax)
  
   # calculate state tax and add it to the list
   if state.lower() in ['california','nevada','arizona','washington']:
       state_tax = salary*.10
   elif state.lower() in ['texas','new mexico','albama']:
       state_tax = salary*.09
   elif state.lower() in ['new york','illinois','wisconsin','delaware']:
       state_tax = salary*.08
   else:
       state_tax = salary*.12
      
   state_tax_list.append(state_tax)

# display all the details of all the 5 employees
print('\nEmployee Details: ')
for i in range(5):
   print('Name: %s'%name_list[i])
   print('Salary : $%.2f'%salary_list[i])
   print('State: %s'%state_list[i])
   print('Federal tax: $%.2f'%federal_tax_list[i])
   print('State tax: $%.2f'%state_tax_list[i])
   # calculate and display the net salary
   print('Net Salary: $%.2f'%(salary_list[i]-federal_tax_list[i]-state_tax_list[i]))
   print('')
#end of program  
  
Code Screenshot:

Python version : 3.6 Python program to input the name, salary and state of 5 employees and calculate the federal and state ta

# calculate state tax and add it to the list if state. lower() in [california, nevada, arizona, washington]: state_ta

Output:

Enter the details for Employee-1 Name: John Smith Salary: 85000 State: California Enter the details for Employee-2 Name: Shau

Employee Details: Name: John Smith Salary : $85000.00 State: California Federal tax: $12750.00 State tax: $8500.00 Net Salary

Add a comment
Know the answer?
Add Answer to:
Please do this in Python 3 DESCRIPTION Using For.. loop, Write a program to fetch the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • My project has to do with the average tuition for in-state students per semester and the proportion of western states th...

    My project has to do with the average tuition for in-state students per semester and the proportion of western states that pay less than $5000 for tuition. Western states include Alaska, Arizona, California, Colorado, Hawaii, Idaho, Montana, Nevada, New Mexico, Oregon, Utah, Washington and Wyoming. I need help with the best method of graphing this and how to create the confidence intervals for 95% for BOTH the average tuition for in state students AND the proportion of western states that...

  • Program Gross Pay. Implement this program using functions. Please pay attention to the requirements Function should...

    Program Gross Pay. Implement this program using functions. Please pay attention to the requirements Function should have 1 parameter for gross salary. Return is net salary. Print out employee name and net salary. Write a program to fetch employee name and the salary. Calculate the Federal tax and state tax based on the following criteria: If the salary is greater than 100000 then calculate the federal tax at 15% otherwise calculate the federal tax at 10% Calculate the state tax...

  • TEST SAMPLE SIZE: 30 TEST TAX RANGE: ? STANDARD DEVIATION: ? MEAN : ? We took...

    TEST SAMPLE SIZE: 30 TEST TAX RANGE: ? STANDARD DEVIATION: ? MEAN : ? We took 15 states with the highest tax rate and 15 state with the lowest tax rate. We are going to set alpha to .1 to determine the covariance with 90% confidence *Please answer the top part and also state whether the test rejects the null or does not reject the null hypothesis. State Lowest Rate State Highest Rate Alaska 6.5% New York 12.7% Wyoming 7.1%...

  • Rate 3% 12% 14% 8% 9% 596 State Rate State 1090 | Kansas 11% Kentucky 13%...

    Rate 3% 12% 14% 8% 9% 596 State Rate State 1090 | Kansas 11% Kentucky 13% Louisiana 1296 | Maine 8% Maryland 690 590 | Michigan 890 | Minnesota 996 | Mississippi 1196 | Missouri 1390 | Montana 1090 | Nebraska 996 | Nevada 996| New Hampshire 590 796 | New Jersey 1290 | South Dakota 996 | Tennessee Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa New Mexico New York North Carolina...

  • Write a C# windows forms program to create a States and Capitals guessing game. A method...

    Write a C# windows forms program to create a States and Capitals guessing game. A method in your program should generate a random number between 1 and 50. Your program should use this number to represent one of the 50 U.S states and then display the name of that state. The user will guess the capital of that state. Another method in your program should get the users answer and check to see whether it is correct. Yet another method...

  • Please explain how each step is performed. TABLE 1. SOFT DRINK DEMAND DATA State Cans/Capita/Yr 6-Pack...

    Please explain how each step is performed. TABLE 1. SOFT DRINK DEMAND DATA State Cans/Capita/Yr 6-Pack Price ($) IncomelCapita ($1,000) Mean Temp. (F) Alabama Arizona Arkansas California Colorado Connecticut Delaware 200 150 237 135 1.99 1.93 15.3 18.1 25.2 16.2 1.99 242 295 64 Georgia Idaho Illinois Indiana lowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island...

  • Please Help!(Write a C++ program Only):- The attached file has a number of records giving US...

    Please Help!(Write a C++ program Only):- The attached file has a number of records giving US state names, populations, and number of Federal electors. The fields are delimited by spaces. The first field is a single integer giving the number of states that follow. Guidelines:- 1)Read the first integer and use it to allocate dynamic arrays to contain the state name and the state population. 2) Read in the population data. The electors field is not used. 3) Calculate the...

  • C++ how can I input this data correctly? State, Coal, Natural Gas, Fuel Oil, Jet Fuel,HGL...

    C++ how can I input this data correctly? State, Coal, Natural Gas, Fuel Oil, Jet Fuel,HGL Other, Motor Gasoline, Residual Fuel Oil, Nuclear Electric Power, Hydroelectric Power, Wood and Waste, Fuel Ethanol, Geothermal, Solar, Wind Alabama,410.20,715.70,169.40,18.00,44.90,309.10,11.90,417.30,64.50,167.40,23.70,0.10,0.40,0.00 Alaska,16.60,330.90,64.40,104.80,28.60,35.20,0.00,0.00,15.30,2.30,0.00,0.20,0.05,1.60 Arizona,323.90,371.50,149.10,24.90,33.90,324.30,0.00,338.60,66.20,6.60,24.70,0.30,52.80,5.00 Arkansas,246.40,315.70,113.60,8.50,36.40,170.10,0.05,140.40,33.00,77.90,13.00,0.80,0.40,0.00 California,32.10,2248.40,560.40,672.60,383.00,1714.40,145.80,197.80,267.20,137.00,131.30,107.90,267.10,124.70 Colorado,321.50,501.10,103.90,52.50,50.20,263.80,0.00,0.00,17.60,10.60,20.20,0.80,9.50,87.00 Connecticut,2.30,254.70,94.90,9.50,25.10,168.30,0.80,173.40,2.10,25.20,12.90,0.05,4.10,0.10 Delaware,8.20,113.60,14.30,0.70,32.80,54.30,1.10,0.00,0.00,1.80,4.20,0.40,1.10,0.05 DC,0.05,30.10,2.80,0.00,3.45,13.30,0.00,0.00,0.00,0.80,1.00,0.05,0.30,0.00 Florida,426.20,1414.10,312.10,155.40,86.30,1008.80,59.10,306.70,1.60,182.50,69.80,10.10,30.20,0.00 Georgia,399.30,728.00,226.50,29.30,58.40,540.30,8.50,360.60,31.10,214.20,37.40,0.30,10.20,0.00 Hawaii,16.40,0.20,26.20,74.30,20.90,52.80,60.90,0.00,0.80,8.50,4.00,2.40,9.80,5.90 Idaho,2.40,110.30,70.90,5.50,13.20,88.20,0.05,0.00,83.40,22.70,6.70,2.20,0.40,23.80 Illinois,702.50,1045.20,297.30,161.00,241.50,544.70,0.60,1031.30,1.20,24.30,40.30,2.00,2.00,98.40 Indiana,948.40,780.10,235.00,50.20,121.10,357.50,1.70,0.00,3.90,30.40,25.20,4.60,2.40,45.20 Iowa,298.00,317.20,150.10,5.50,84.90,192.10,0.05,49.20,8.50,20.10,16.30,1.30,0.60,185.30 Kansas,253.10,278.10,119.50,8.70,59.80,154.20,3.60,86.20,0.30,6.30,10.70,1.00,0.10,130.30 Kentucky,736.60,284.10,156.20,68.00,123.70,250.80,0.05,0.00,32.10,35.20,17.80,2.70,0.40,0.00 Louisiana,140.50,1697.40,192.20,166.10,1253.90,254.50,37.70,179.40,10.20,136.30,19.50,1.80,1.80,0.00 Maine,2.20,54.50,70.70,6.50,20.30,89.60,3.80,0.00,27.70,90.60,6.60,0.10,0.40,15.40 Maryland,162.90,229.60,98.50,8.80,33.70,306.50,0.70,154.40,12.90,26.00,23.20,0.60,6.80,4.90 Massachusetts,20.10,442.70,144.60,60.90,33.90,315.10,4.70,56.60,6.60,37.40,24.10,0.90,17.50,2.00 Michigan,471.20,927.50,171.70,22.80,119.00,536.90,3.20,330.00,14.40,92.90,37.30,5.20,1.10,43.40 Minnesota,261.20,466.50,160.30,27.30,113.60,296.10,0.80,145.00,11.20,72.50,27.60,1.10,0.60,91.70 Mississippi,61.20,563.40,122.00,97.20,63.00,196.10,3.60,61.70,0.00,56.30,15.00,1.00,0.10,0.00 Missouri,639.90,273.60,188.10,16.60,57.00,362.70,0.10,98.60,11.70,26.40,26.10,0.40,1.90,10.40 Montana,161.90,77.60,50.20,5.40,50.80,61.00,0.00,0.00,93.10,4.40,4.70,0.30,0.10,19.80 Nebraska,240.50,172.90,111.40,7.50,17.70,102.20,0.00,97.80,7.90,4.10,7.10,1.20,0.10,35.10 Nevada,30.80,316.00,64.30,35.00,14.10,131.80,0.00,0.00,16.50,2.50,10.00,32.50,33.30,3.20 New Hampshire,5.30,59.50,40.30,2.50,21.60,80.20,1.50,112.60,10.60,35.80,6.00,0.05,0.50,4.00 New Jersey,17.50,795.10,176.30,187.20,109.40,469.70,25.00,312.60,0.10,28.40,35.90,0.50,22.20,0.20 New Mexico,197.10,259.60,92.30,7.20,30.80,107.80,0.00,0.00,1.40,6.30,8.30,0.50,8.60,33.30 New York,29.70,1335.10,330.10,201.20,98.70,635.30,40.00,434.80,248.20,76.50,46.60,1.20,10.60,36.40 North Carolina,381.80,540.20,190.90,14.90,81.50,531.00,0.50,447.50,40.80,110.20,36.70,1.00,33.40,0.10 North Dakota,394.60,105.80,84.80,5.60,27.40,49.60,0.00,0.00,17.70,2.60,3.80,1.00,0.05,75.40 Ohio,825.30,996.90,290.50,67.40,180.50,576.80,3.90,175.90,4.60,52.70,40.10,3.40,1.90,11.50 Oklahoma,221.80,738.40,175.00,52.60,83.30,222.40,2.60,0.00,23.80,31.00,15.50,0.05,0.10,185.30 Oregon,19.40,249.80,100.20,28.60,24.60,178.50,0.80,0.00,319.00,59.40,13.50,2.90,3.10,66.10 Pennsylvania,734.80,1363.80,327.30,69.20,188.70,556.60,3.50,867.30,21.90,104.70,39.80,2.20,4.10,32.10...

  • Listed below is the median household income for the 50 states and the District of Columbia....

    Listed below is the median household income for the 50 states and the District of Columbia. State, Amount Alabama 42278 Alaska 67629 Arizona 49254 Arkansas 44922 California 60487 Colorado 60940 Connecticut 70161 Delaware 57522 DC 68277 Florida 46140 Georgia 49555 Hawaii 71223 Idaho 53438 Illinois 54916 Indiana 48060 Iowa 57810 Kansas 53444 Kentucky 42786 Louisiana 42406 Maine 51710 Maryland 76165 Massachusetts 63151 Michigan 52005 Minnesota 67244 Mississippi 35521 Missouri 56630 Montana 51102 Nebraska 56870 Nevada 49875 New Hampshire 73397 New...

  • Where are the nurses? Table 1.5 gives the number of ac- tive nurses per 100,000 people...

    Where are the nurses? Table 1.5 gives the number of ac- tive nurses per 100,000 people in each state.5 .35 URSES (a) Why is the number of nurses per 100,000 people a better measure of the availability of nurses than a simple count of the number of nurses in a state? (b) Make a histogram that displays the distribution of nurses per 100,000 people. Write a brief description of the distribution. Are there any outliers? If so, can you explain...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT