Question: I need help implementing the following functions init() , genderDistribution() , collegeDistribution() , departmentDistribution(), majorDistribution(), termDistribution(). into the code given The instructions for each function

I need help implementing the following functions init(), genderDistribution(), collegeDistribution(),departmentDistribution(), majorDistribution(), termDistribution(). into the code given The instructions for each function are below, thank you so much for the help!

file: https://1drv.ms/x/s!Aj0EGBNy0RCLjRNKqeES3U3cPAXE

I need help implementing the following functions init(), genderDistribution(), collegeDistribution(),departmentDistribution(), majorDistribution(), termDistribution().into the code given The instructions for each function are below, thank

import diversityanalysis

def printTitle(title): print(' F M F/M '+title)

def printDistribution(gender, item): f = gender.get('F',0) m = gender.get('M',0) r = f/m if m > 0 else 0.0 print("%6d %6s %3.1f %s" % (f, m, r, item))

def main():

diversityanalysis.init('genderdata.csv')

gender = diversityanalysis.genderDistribution() printTitle('Total') printDistribution(gender,"Gender")

college = diversityanalysis.collegeDistribution() printTitle('College') for k in sorted(college.keys()): 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()): printDistribution(major[k],k)

term = diversityanalysis.termDistribution() printTitle('Term') for k in sorted(term.keys()): printDistribution(term[k],k)

main()

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 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!