Question: Programming in Python. From the data, I want to return a dictionary with age group and gender as its keys - the value totals all

Programming in Python.

From the data, I want to return a dictionary with age group and gender as its keys - the value totals all the countries in the region's data for that age group and gender. I am not allowed to use class for this assignment. I can only use dictionaries, lists, and tuples.

data = {'Australia': {'20-24': [('Female', 'Rural', 192), ('Male', 'Urban', 1550)], '35-39': [('Female', 'Urban', 11780), ('Male', 'Rural', 1424)], '50-54': [('Female', 'Rural', 5219), ('Male', 'Rural', 6533)], '65-69': [('Female', 'Urban', 83815), ('Male', 'Urban', 92794)]}, 'French Polynesia': {'20-24': [('Female', 'Rural', 643, 5226), ('Male', 'Urban', 504)], '35-39': [('Female', 'Rural', 1016), ('Male', 'Rural', 807)], '50-54': [('Female', 'Urban', 1610), ('Male', 'Rural', 1287)], '65-69': [('Female', 'Urban', 825), ('Male', 'Urban', 792)]}}

output = {'50-54': {'MALE': 7820, 'FEMALE': 6829}, '35-39': {'MALE': 2231, 'FEMALE': 12796}, '65-69': {'MALE': 93586, 'FEMALE': 84640}, '20-24': {'MALE': 2054, 'FEMALE': 835}}

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!