Question: I need to answer these questions using functions that use the dictionary I am going to create: 1: If we add up the individual state
I need to answer these questions using functions that use the dictionary I am going to create:
1: If we add up the individual state unauthorized immigration population ("Unauthorized immigrant population"), do we get the same value as in the summative row labeled "U.S."? (Food for thought: why aren't they the same?)
2: Which states have a larger percentage unauthorized immigrant population ("Unauthorized immigrant % of population") than the value in the summative row labeled "U.S."?
3: Consider the column on the industry with the largest number of unauthorized immigrant workers ("Industry with largest number of unauthorized immigrant workers"). Which industry is listed as the largest in the most states and how many states?
4: What are the occupations with the largest percentage of workers who are unauthorized immigrants across the nation?
5: Which states have a percentage of K-12 students with at least one unauthorized immigrant parent above 10%?
In addition to main, write a function to read in the data from the CSV file into a dictionary that uses the state name as the key and that maps to dictionary. The keys for these nested dictionaries will come from the first row of the CSV file (minus the state name) and the values will be the data from each subsequent row (again, skipping the name of the state). An excerpt from this dictionary is shown below. Then, write functions to produce the answer to each of the questions above. You may find you need or want to write additional functions to simplify your code. You are free to write as many additional functions as you deem necessary.
Additional Notes:
The csv file is in UTF-8 with BOM format. For more information about what exactly this means, see What Every Developer Must Know About Encoding and Unicode. It's a very interesting read! For tips on how to handle UTF-8 with BOM see Reading Unicode file data with BOM chars in Python. While you don't need it, Python's csv module may prove handy. Especially csv.DictReader. Read more about using it in Reading and Writing CSV Files in Python
Here is the CSV file info: (Copy into a notes file then save as CSV)
State,Unauthorized immigrant population,Unauthorized immigrant % of population,Unauthorized % of immigrant population,% of K-12 students with unauthorized immigrant parent(s),% Mexican of unauthorized immigrants,% of unauthorized immigrant adults in the U.S. for 5 years or less,Change in unauthorized immigrant population 2007-2016,Unauthorized immigrant % of labor force,Industry with largest number of unauthorized immigrant workers,Industry with largest % of workers who are unauthorized immigrants,Occupation with largest number of unauthorized immigrant workers,Occupation with largest % of workers who are unauthorized immigrants U.S.,"10,700,000",3.30%,24%,7.60%,51%,18%,"-1,550,000",4.80%,Construction,Agriculture,Service,Farming Alabama,"55,000",1.20%,34%,3.30%,59%,13%,"-15,000",1.70%,Construction,Construction,Service,Farming Alaska,"5,000",1.00%,13%,0.50%,23%,43%,"Not sig",1.70%,Manufacturing,Manufacturing,Production,Production Arizona,"275,000",3.90%,28%,10.70%,78%,13%,"-220,000",5.70%,Business services,Agriculture,Service,Farming Arkansas,"55,000",1.90%,41%,6.30%,64%,15%,"-10,000",2.80%,Manufacturing,Construction,Service,Construction California,"2,200,000",5.60%,20%,13.30%,69%,10%,"-550,000",8.60%,Leisure/hospitality,Agriculture,Service,Farming Colorado,"190,000",3.40%,34%,10.60%,70%,14%,"Not sig.",4.60%,Construction,Construction,Service,Construction Connecticut,"120,000",3.50%,23%,6.90%,14%,21%,"Not sig.",4.90%,Business services,Construction,Service,Construction Delaware,"30,000",3.00%,31%,7.00%,38%,29%,"Not sig.",4.20%,Construction,Construction,Service,Farming "District of Columbia","25,000",3.80%,28%,9.00%,5%,21%,"Not sig.",4.70%,Leisure/hospitality,Construction,Service,Construction Florida,"775,000",3.80%,18%,7.10%,15%,29%,"-240,000",5.60%,Construction,Agriculture,Service,Farming Georgia,"400,000",3.80%,36%,8.60%,49%,17%,"Not sig.",5.40%,Construction,Construction,Service,Construction Hawaii,"45,000",3.30%,17%,7.00%,6%,34%,"Not sig.",4.50%,Leisure/hospitality,Agriculture,Service,Farming Idaho,"35,000",2.20%,37%,5.70%,79%,19%,"Not sig.",3.10%,Agriculture,Agriculture,Service,Farming Illinois,"400,000",3.20%,22%,7.80%,71%,11%,"-140,000",4.80%,Manufacturing,Manufacturing,Service,Production Indiana,"100,000",1.50%,29%,4.20%,59%,23%,"Not sig.",2.10%,Manufacturing,Agriculture,Service,Farming Iowa,"50,000",1.70%,31%,4.20%,56%,26%,"Not sig.",2.20%,Manufacturing,Manufacturing,Production,Farming Kansas,"75,000",2.60%,35%,7.60%,69%,16%,"Not sig.",3.70%,Manufacturing,Construction,Service,Construction Kentucky,"35,000",0.80%,22%,1.60%,48%,24%,"Not sig.",1.10%,Construction,Agriculture,Service,Farming Louisiana,"70,000",1.50%,36%,2.70%,28%,23%,"15,000",2.00%,Construction,Construction,Construction,Construction Maine,"<5,000",0.40%,9%,0.50%,-,-,"Not sig.",0.40%,-,-,-,- Maryland,"275,000",4.50%,29%,8.50%,9%,22%,"60,000",6.40%,Construction,Construction,Service,Farming Massachusetts,"250,000",3.80%,22%,6.10%,2%,29%,"35,000",5.10%,Business services,Construction,Service,Farming Michigan,"100,000",1.00%,15%,2.20%,29%,27%,"-45,000",1.40%,Manufacturing,Agriculture,Service,Farming Minnesota,"95,000",1.70%,20%,3.80%,50%,21%,"Not sig.",2.20%,Manufacturing,Agriculture,Service,Farming Mississippi,"20,000",0.70%,35%,1.80%,59%,21%,"Not sig.",1.00%,Construction,Construction,Construction,Construction Missouri,"60,000",1.00%,23%,2.70%,45%,20%,"Not sig.",1.50%,Leisure/hospitality,Mining,Service,Construction Montana,"<5,000",0.30%,12%,0.10%,-,-,"Not sig.",0.50%,-,-,-,- Nebraska,"60,000",3.10%,41%,9.20%,62%,14%,"Not sig.",3.60%,Manufacturing,Manufacturing,Service,Construction Nevada,"210,000",7.10%,35%,20.20%,66%,12%,"-35,000",10.60%,Leisure/hospitality,Agriculture,Service,Farming New Hampshire,"10,000",0.70%,13%,0.90%,6%,36%,"Not sig.",0.90%,Manufacturing,Manufacturing,Service,Production New Jersey,"475,000",5.20%,22%,8.80%,23%,21%,"-90,000",7.60%,Business services,Agriculture,Service,Farming New Mexico,"60,000",2.80%,29%,7.90%,91%,12%,"-25,000",4.20%,Construction,Construction,Service,Construction New York,"725,000",3.60%,15%,6.60%,24%,20%,"-300,000",5.40%,Leisure/hospitality,Construction,Service,Construction North Carolina,"325,000",3.10%,39%,8.90%,56%,16%,"Not sig.",4.50%,Construction,Agriculture,Service,Farming North Dakota,"5,000",0.70%,23%,1.70%,-,-,"Not sig.",0.80%,-,-,-,- Ohio,"90,000",0.80%,17%,1.40%,25%,33%,"Not sig.",1.00%,Manufacturing,Agriculture,Service,Farming Oklahoma,"85,000",2.20%,38%,6.40%,78%,15%,"Not sig.",3.20%,Construction,Construction,Service,Farming Oregon,"110,000",2.60%,26%,8.20%,69%,16%,"-40,000",3.90%,Agriculture,Agriculture,Service,Farming Pennsylvania,"170,000",1.30%,19%,2.40%,21%,31%,"Not sig.",1.70%,Business services,Agriculture,Service,Farming Rhode Island,"30,000",2.80%,19%,6.80%,8%,28%,"Not sig.",3.60%,Manufacturing,Manufacturing,Service,Production South Carolina,"85,000",1.70%,35%,4.40%,54%,20%,"Not sig.",2.60%,Construction,Agriculture,Service,Farming South Dakota,"5,000",0.70%,19%,1.20%,-,-,"Not sig.",0.90%,-,-,-,- Tennessee,"130,000",2.00%,38%,5.20%,56%,23%,"Not sig.",2.80%,Construction,Construction,Service,Construction Texas,"1,600,000",5.70%,33%,13.30%,73%,16%,"Not sig.",8.20%,Construction,Construction,Service,Construction Utah,"95,000",3.20%,38%,7.50%,71%,14%,"Not sig.",4.80%,Manufacturing,Agriculture,Service,Farming Vermont,"<5,000",0.10%,4%,0.20%,-,-,"Not sig.",0.20%,-,-,-,- Virginia,"275,000",3.40%,27%,6.90%,12%,23%,"Not sig.",4.70%,Construction,Construction,Service,Farming Washington,"240,000",3.30%,23%,8.90%,56%,17%,"Not sig.",4.70%,Agriculture,Agriculture,Service,Farming West Virginia,"<5,000",0.20%,14%,0.50%,-,-,"Not sig.",0.30%,-,-,-,- Wisconsin,"75,000",1.30%,24%,3.60%,70%,15%,"Not sig.",1.80%,Manufacturing,Agriculture,Service,Farming Wyoming,"5,000",1.20%,32%,3.90%,-,-,"Not sig.",1.60%,-,-,-,-
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
