Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with as much of this as possible would be awesome. In python please, thank you! file: https://1drv.ms/x/s!Aj0EGBNy0RCLjWRF51Lye2y56X8H The assignment has two files diversity.py is
Help with as much of this as possible would be awesome. In python please, thank you!
file: https://1drv.ms/x/s!Aj0EGBNy0RCLjWRF51Lye2y56X8H
The assignment has two files diversity.py is a script containing the main program and all printing. It is provided for you and you may not change it. There are several calls to functions in the diversityanalysis module that you implement. diversityanalysis.py is a module that you must write to analyze the file and return the data via other The file is very large so you should only read it once. It is expected that you will complete the analysis as you read the file and place the results in dictionaries during the init function. The other functions can simply return the dictionaries you created in the init function. This program will require you to work with modules, global variables, CSV files, and nested dictionaries You will be writing a module. The module should not have a main or call any of its functions at the top level. It should only define functions and global variables As a convention, you might want to start all of the global variables in the module with an (underscore) so they stand out. These will be a useful place to hold the dictionaries you create during the analysis . You need to implement below functions 1 init0 This function should parse your CSV file and read all the lines. Lines read by this function should be reused by rest of the functions. In this way you avoid reading file multiple times for each of your functions 2. genderDistribution0-Should return a dictionary for entire M and F population in the school 3. collegeDistribution0 - Should return a nested dictionary for each of the college in the school with it's respective M and F population 4. departmentDistribution0 Should return a nested dictionary for each of the department in the school with it's respective M and F population 5. majorDistribution0 - Should return a nested dictionary for each of the major in the school with it's respective M and F population 6. termDistributionO - Should return a nested dictionary for each term in the school with it's respective M and F population .For each of the below columns, create a dictionary with M and F population: e College o Department o Major Term In most cases, dictionaries are nested so you might want to review how to create, access, and update nested dictionaries .Comma Separate Value (CSV) files are fairly common and useful since they may easily to loaded into a spreadsheet for analysis 1 import diversityanalysis 4 def printTitle(title): print('n F M F/M +title) 8 def printDistribution(gender, item) f gender.get('F',e) m gender get('M',0) rf/m if m 0 else 0.0 10 12 13 14 15 def main): 16 17 18 19 20 21 printDistribution (gender, "Gender") print ("%6d %6s %3.1f %s" % (f, m, r, item)) diversityanalysis.init('genderdata.csv') genderdiversityanalysis.genderDistribution() printTitle('Total') college diversityanalysis.collegeDistribution() printTitle( 'College') for k in sorted (college.keys ()): 23 24 25 26 27 28 29 30 31 32 printDistribution (college[k],k) department-diversityanalysis.departmentDistribution() printTitle( 'Department') for k in sorted(department.keys()) printDistribution (department[k],k) major diversityanalysis.majorDistribution() printTitle ( 'Major') for k in sorted (major.keys()) 34 35 36 37 38 printDistribution (major[k],k) termdiversityanalysis.termDistribution() printTitle('Term for k in sorted(term.keys()): 40 41 42 43 44 main printDistribution(term[k],k) The assignment has two files diversity.py is a script containing the main program and all printing. It is provided for you and you may not change it. There are several calls to functions in the diversityanalysis module that you implement. diversityanalysis.py is a module that you must write to analyze the file and return the data via other The file is very large so you should only read it once. It is expected that you will complete the analysis as you read the file and place the results in dictionaries during the init function. The other functions can simply return the dictionaries you created in the init function. This program will require you to work with modules, global variables, CSV files, and nested dictionaries You will be writing a module. The module should not have a main or call any of its functions at the top level. It should only define functions and global variables As a convention, you might want to start all of the global variables in the module with an (underscore) so they stand out. These will be a useful place to hold the dictionaries you create during the analysis . You need to implement below functions 1 init0 This function should parse your CSV file and read all the lines. Lines read by this function should be reused by rest of the functions. In this way you avoid reading file multiple times for each of your functions 2. genderDistribution0-Should return a dictionary for entire M and F population in the school 3. collegeDistribution0 - Should return a nested dictionary for each of the college in the school with it's respective M and F population 4. departmentDistribution0 Should return a nested dictionary for each of the department in the school with it's respective M and F population 5. majorDistribution0 - Should return a nested dictionary for each of the major in the school with it's respective M and F population 6. termDistributionO - Should return a nested dictionary for each term in the school with it's respective M and F population .For each of the below columns, create a dictionary with M and F population: e College o Department o Major Term In most cases, dictionaries are nested so you might want to review how to create, access, and update nested dictionaries .Comma Separate Value (CSV) files are fairly common and useful since they may easily to loaded into a spreadsheet for analysis 1 import diversityanalysis 4 def printTitle(title): print('n F M F/M +title) 8 def printDistribution(gender, item) f gender.get('F',e) m gender get('M',0) rf/m if m 0 else 0.0 10 12 13 14 15 def main): 16 17 18 19 20 21 printDistribution (gender, "Gender") print ("%6d %6s %3.1f %s" % (f, m, r, item)) diversityanalysis.init('genderdata.csv') genderdiversityanalysis.genderDistribution() printTitle('Total') college diversityanalysis.collegeDistribution() printTitle( 'College') for k in sorted (college.keys ()): 23 24 25 26 27 28 29 30 31 32 printDistribution (college[k],k) department-diversityanalysis.departmentDistribution() printTitle( 'Department') for k in sorted(department.keys()) printDistribution (department[k],k) major diversityanalysis.majorDistribution() printTitle ( 'Major') for k in sorted (major.keys()) 34 35 36 37 38 printDistribution (major[k],k) termdiversityanalysis.termDistribution() printTitle('Term for k in sorted(term.keys()): 40 41 42 43 44 main printDistribution(term[k],k)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started