Question
Python Programming More details can be found here Skeleton code: https://www.cse.msu.edu/~cse231/Online/Projects/Project08/proj08.py PDF description of the assignment: https://www.cse.msu.edu/~cse231/Online/Projects/Project08/Project_08.pdf #code of function get dictionary def create_dictionary(file_obj): '''
Python Programming
More details can be found here
Skeleton code:
https://www.cse.msu.edu/~cse231/Online/Projects/Project08/proj08.py
PDF description of the assignment:
https://www.cse.msu.edu/~cse231/Online/Projects/Project08/Project_08.pdf
#code of function get dictionary
def create_dictionary(file_obj): ''' Place Docstring here! ''' D={} file_obj.readline() for line in file_obj: line_list = line.strip().split(',') country = line_list[1] region = line_list[2] age_group = line_list[3] gender = line_list[4] geographic_area = line_list[5] diabetes = int(float(line_list[6])*1000) population = int(float(line_list[7])*1000) tup = (gender, geographic_area, diabetes, population) if region not in D: D[region] = {} if country not in D[region]: D[region][country]= {} if age_group not in D[region][country]: D[region][country][age_group]= [tup] else: D[region][country][age_group].append(tup) return D
c) get country total(data) This function receives a dictionary from a specific region, and returns a new dictionary of tuples with the number of people with diabetes and the total population for each country-the country name is the key, the tuple has total number of people with diabetes followed by the total population for the countryStep 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