Python 3 Question Do NOT use global variables (This is an edit to a question I've asked before because I forgot to include a template. So if you have answered this question already I ask that you do not copy and paste a previous answer.) PLEASE use the template given, keep the code introductory friendly, and include comments. Many thanks. Prompt: The results of a survey of the households in your township are available for public scrutiny. Each record contains data for one household, including a four-digit integer identification number, the annual income for the household, and the number of household members. Write a program to read the survey results into three lists and perform the following analysis. a) Print the record of each household included in the survey in a three-column format with headings. b) Calculate and print the average household income. c) List the identification number and income of each household that exceeds the average. d) Determine and print the identification number and income of households that have income below the 2018 United States’ Contiguous States poverty level. e) Determine and print the percentage of households that have income below the 2018 United States’ Contiguous States poverty level. Compute the poverty level income using the formula below. povertyLevel = 16460.00 + 4320.00 * (m – 2) where m is the number of members of each household. This formula shows that the poverty level depends on the number of family members, m, and the poverty level income increases as m gets larger. The input data is 1042 12180.06 3 1062 13240.45 2 1327 19800.56 2 1483 22458.23 7 1900 17000.09 3 2112 18125 4 2345 15623 2 3210 3200 1 3600 39500 5 3601 11970 2 4724 8900 3 6217 45000.70 2 9280 6200 1 1000 31000 3 1200 36000 2 5601 51970 9 5724 66900 3 5217 10002.68 2 5280 70000 1 5000 100000 6 5200 25000.4 3 5230 120000 6 6641 85000 7 7000 45500 4 7100 56500 3 8110 110005.9 8 9101 67590.40 6
and has the format of identification number, annual income for the household, and the number of household members.
No input, processing or output should happen in the main function. All work should be delegated to other functions. The program should have at least 5 functions (main and developerInfo included) and the output sent to an output file, Program10-out.txt.
(This is the program template given)
def main():
inFile = open('program10.txt', 'r')
outFile = open('program10-out.txt', 'w')
outFile.write(str("%12s %12s %16s\n" % ("Account #", "Income",
"Members")))
lineRead = inFile.readline() # Read first record
while lineRead != '': # While there are more records
words = lineRead.split() # Split the records into substrings
acctNum = int(words[0]) # Convert first substring to integer
annualIncome = float(words[1]) # Convert second substring to
float
members = int(words[2]) # Convert third substring to integer
print("%10d %15.2f %10d" % (acctNum, annualIncome, members))
outFile.write(str("%10d %16.2f %12d\n" % (acctNum, annualIncome,
members)))
lineRead = inFile.readline() # Read next record
# Close the file.
inFile.close() # Close file
# Call the main function.
main()
(this is the developerInfo function)
def developerInfo():
print('Name: name')
print('Course: Programming Fundamentals I')
print('Program: Ten')
print()# averageHouseholdIncome function
# takes one parameter annualIncomeList and return average household income
def averageHouseholdIncome(annualIncomeList):
totalIncome = 0
for income in annualIncomeList:
totalIncome = totalIncome + income
return totalIncome/len(annualIncomeList)
# exceedsAverageIncome function takes two parameter identificationNumList and annualIncomeList
# return lists of identification number and annual income of households whose income exceeds average
def exceedsAverageIncome(identificationNumList, annualIncomeList):
# calling the function averageHouseholdIncome and store average
# in averageIncome variable
averageIncome = averageHouseholdIncome(annualIncomeList)
idNumList = []
incomeList = []
# finding the identification number whose income exceeds average
for i in range(len(annualIncomeList)):
if annualIncomeList[i] > averageIncome:
idNumList.append(identificationNumList[i])
incomeList.append(annualIncomeList[i])
return idNumList, incomeList
# incomeBelowPoverty function which takes 3 parameters
# identificationNumList, annualIncomeList and membersList
# return income List and identification number list of household below poverty line
def incomeBelowPoverty(identificationNumList, annualIncomeList, membersList):
idNumList = []
incomeList = []
# finding the households whose income is below poverty line
for i in range(len(membersList)):
povertyLevel = 16460.00 + 4320.00 * (int(membersList[i]) - 2)
if povertyLevel > annualIncomeList[i]:
idNumList.append(identificationNumList[i])
incomeList.append(annualIncomeList[i])
return idNumList, incomeList
# percentBelowPoverty function which takes 2 parameters
# totalNumOfHouseholds and numOfHouseholdsBelowPovertyLine
# return percentage of household below poverty line
def percentBelowPoverty(totalNumOfHouseholds, numOfHouseholdsBelowPovertyLine):
return (numOfHouseholdsBelowPovertyLine * 100)/totalNumOfHouseholds
# main function
def main():
inFile = open('program10.txt', 'r')
outFile = open('program10-out.txt', 'a')
# list variables
identificationNumList = []
annualIncomeList = []
membersList = []
outFile.write("Record of each household included in the survey\n")
outFile.write(str("%12s %12s %16s\n" % ("Account #", "Income", "Members")))
print("Record of each household included in the survey\n")
print(str("%12s %12s %16s\n" % ("Account #", "Income", "Members")))
lineRead = inFile.readline() # Read first record
while lineRead != '': # While there are more records
words = lineRead.split() # Split the records into substrings
acctNum = int(words[0]) # Convert first substring to integer
annualIncome = float(words[1]) # Convert second substring to float
members = int(words[2]) # Convert third substring to integer
# appending to the list variables
identificationNumList.append(acctNum)
annualIncomeList.append(annualIncome)
membersList.append(members)
print("%10d %15.2f %10d" % (acctNum, annualIncome, members))
outFile.write(str("%10d %16.2f %12d\n" % (acctNum, annualIncome, members)))
lineRead = inFile.readline() # Read next record
# Close the file.
inFile.close()
# calculating average household income by calling function averageHouseholdIncome
avgIncome = averageHouseholdIncome(annualIncomeList)
outFile.write("\nAverage Household Income: "+str("%16.2f\n" % (avgIncome)))
print(("\nAverage Household Income: "+str("%10.2f\n" % (avgIncome))))
# Listing the identification number and income of each household that exceeds the average
# and wrting to the file
outFile.write("\nList of the identification number and income of each household that exceeds the average\n")
outFile.write(str("%12s %12s\n" % ("Account #", "Income")))
print("\nList of the identification number and income of each household that exceeds the average")
print(str("%12s %12s" % ("Account #", "Income")))
idNumList, incomeList = exceedsAverageIncome(identificationNumList, annualIncomeList)
for i in range(len(idNumList)):
outFile.write(str("%10d %16.2f\n" % (idNumList[i], incomeList[i])))
print(str("%10d %16.2f" % (idNumList[i], incomeList[i])))
# Determine and print the identification number and income of households that have
# income below the 2018 United States’ Contiguous States poverty level.
outFile.write("\nList of Identification number and income of households that have income below the 2018 United States’ Contiguous States poverty level.\n")
outFile.write(str("%12s %12s\n" % ("Account #", "Income")))
print("\nList of Identification number and income of households that have income below the 2018 United States’ Contiguous States poverty level. ")
print(str("%12s %12s" % ("Account #", "Income")))
idNumList, incomeList = incomeBelowPoverty(identificationNumList, annualIncomeList, membersList)
for i in range(len(idNumList)):
outFile.write(str("%10d %16.2f\n" % (idNumList[i], incomeList[i])))
print(str("%10d %16.2f" % (idNumList[i], incomeList[i])))
# Determine and print the percentage of households that have
# income below the 2018 United States’ Contiguous States poverty level.
perBelowPoverty = percentBelowPoverty(len(membersList), len(idNumList))
outFile.write("\nPercentage of households that have income below the 2018 United States Contiguous States poverty level: %2.2f " %(perBelowPoverty)+ "%")
print("\nPercentage of households that have income below the 2018 United States Contiguous States poverty level: %2.2f" %(perBelowPoverty)+"%")
# Call the main function.
main()
# (this is the developerInfo function)
# note:- didn't touch this part because it needs your info
def developerInfo():
print('Name: name')
print('Course: Programming Fundamentals I')
print('Program: Ten')
print()
Screenshots of running code and output:






program10-out.txt file which is output
file:
Record of each household included in the survey
Account # Income Members
1042 12180.06 3
1062 13240.45 2
1327 19800.56 2
1483 22458.23 7
1900 17000.09 3
2112 18125.00 4
2345 15623.00 2
3210 3200.00 1
3600 39500.00 5
3601 11970.00 2
4724 8900.00 3
6217 45000.70 2
9280 6200.00 1
1000 31000.00 3
1200 36000.00 2
5601 51970.00 9
5724 66900.00 3
5217 10002.68 2
5280 70000.00 1
5000 100000.00 6
5200 25000.40 3
5230 120000.00 6
6641 85000.00 7
7000 45500.00 4
7100 56500.00 3
8110 110005.90 8
9101 67590.40 6
Average Household Income: 41061.76
List of the identification number and income of each household
that exceeds the average
Account # Income
6217 45000.70
5601 51970.00
5724 66900.00
5280 70000.00
5000 100000.00
5230 120000.00
6641 85000.00
7000 45500.00
7100 56500.00
8110 110005.90
9101 67590.40
List of Identification number and income of households that have
income below the 2018 United States� Contiguous States poverty
level.
Account # Income
1042 12180.06
1062 13240.45
1483 22458.23
1900 17000.09
2112 18125.00
2345 15623.00
3210 3200.00
3601 11970.00
4724 8900.00
9280 6200.00
5217 10002.68
Percentage of households that have income below the 2018 United States Contiguous States poverty level: 40.74 %
Python 3 Question Do NOT use global variables (This is an edit to a question I've...
1. The level of income below which the federal government classifies a family as poor is called the: A. relative measure of poverty. B. poverty threshold. C. absolute measure of poverty. D. median income threshold. 2. What is the United States government's formal definition of the poverty line? A. It is the annual income level below which a household is exempt from taxes. B. It is a level of annual income equal to total income in society divided by the...
Python 3 Question: All I need is for someone to edit the program with comments that explains what the program is doing (for the entire program) def main(): developerInfo() #i left this part out retail = Retail_Item() test = Cash_Register() test.data(retail.get_item_number(), retail.get_description(), retail.get_unit_in_inventory(), retail.get_price()) answer = 'n' while answer == 'n' or answer == 'N': test.Menu() print() print() Number = int(input("Enter the menu number of the item " "you would like to purchase: ")) if Number == 8: test.show_items() else:...
Question l Migration plays an important role in development and as a strategy for poverty reduction. Burkina Faso, whose conditions for agriculture are far from favorable, has a long history of migratory movement, and migration within West Africa has long taken place in response to drought and low agricultural productivity. In recent decades, migration to destinations outside the African continent and in particular to Western Europe has become more important for migrants from Burkina Faso. el Migration affects the household...
Please only answer 4-8 please, thanks
Question 1 Migration plays an important role in development and as a strategy for poverty reduction. Burkina Faso, whose conditions for agriculture are far from favorable, has a long history of migratory movement, and migration within West Africa has long taken place in response to drought and low agricultural productivity. In recent decades, migration to destinations outside the African continent and in particular to Western Europe has become more important for migrant:s from Burkina...
PYTHON 3 - please show format Question 2. ) Use the Design Recipe to write a function yesOrNo which has no parameters. When called, it gets input from the user until the user types either 'yes' or 'no', at which point the function should return True if the user typed 'yes' and False if the user typed 'no'. Any other entries by the user are ignored and another value must be input. For example: Test Input Result print(yesOrNo()) hello blank...
/*hello everyone. my question is mostly related to the garagetest part of this assignment that i've been working on. i am not sure how to read the file's contents AND put them into variables/an array. should it be in an arraylist? or maybe a regular array? or no arrays at all? i am also not sure how to call the factory method from garagec. i'm thinking something along the lines of [Garage garage = new GarageC.getInstance("GarageC", numFloors, areaofEachFloor);] but i...
1). The retirement benefit of the Social Security program is
considered a progressive benefit with a regressive financing
scheme.
(1) How is the Social Security benefit progressive?
(2) How is its financing scheme regressive?
2). One of the main goals of the ACA (Patient Protection and
Affordable Care Act of 2010, aka Obamacare) was to provide
affordable health care to the uninsured.
1. What were the THREE primary pieces of the law that were meant to
provide coverage for everyone...
Please use Java to write the program The purpose of this lab is to practice using inheritance and polymorphism. We need a set of classes for an Insurance company. Insurance companies offer many different types of policies: car, homeowners, flood, earthquake, health, etc. Insurance policies have a lot of data and behavior in common. But they also have differences. You want to build each insurance policy class so that you can reuse as much code as possible. Avoid duplicating code....
Playgrounds and Performance: Results Management at KaBOOM! (A) We do this work because we want to make a difference in the world; how can we go further faster? - Darell Hammond, CEO and co-founder, KaBOOM! Darell Hammond stepped onto the elementary school playground and took a long, slow look around. It was 8 a.m. on an unusually warm fall day in 2002 and the playground was deserted, but Hammond knew the children would start arriving soon to admire their new...
QUESTION 10
Consider the monthly data, including the estimates for March
2020, and the information in the articles. Which of the following
is the best analysis of and prediction for the money market in the
U.S. economy for the next few months?
a.
Shortages are causing panic buying by households, which has
increased money demand. Lenders are increasing their lending to
keep up with the needs of households and businesses. Money demand
is increasing more than money supply.
b.
Shortages...