(Solved) : O Page Deportes University Saskatchewan Cmpt 141 Na 2009 Question 1 6 Points Purpose Pract Q41358821 . . .

o page Deportes UNIVERSITY OF SASKATCHEWAN CMPT 141 Na 2009 Question 1(6 points): Purpose: To practice the concept of diction

Please do ask if something is not clear

o page Deportes UNIVERSITY OF SASKATCHEWAN CMPT 141 Na 2009 Question 1(6 points): Purpose: To practice the concept of dictionary as a database Degree of Difficulty: Moderate. Before starting this question first download the data file CityData.txt from the class Moodle. Make sure to put it in the same folder as your as.py python code Write a function called rond.citydata that takes as parametorisk • a string indicating the name of a city data file This function should return a database e, a dictionary of dictionaries) that stores all of the City data in a format that we will describe further below. You can review section 11.19 of the text for a refresher on what databases look like using dictionaries Input File Format The data file for this question looks like this: Holiday Park, Ward 2.Spanish, English, French Ukrainian Cree, German North Park, Ward 1, Tagalog, Ukrainian, French, German, English Each line of the file contains all of the data for a single neighbourhood. The first item on the line is always the neighbourhood’s name names are guaranteed to be unic . The second item is always the neighbour hood’s ward, which in the example above is Ward 2 Following that are one or more languages which are spoken in that neighbourhood. So there are residents in Holiday Park that speak Spanish. English, French Ukrainian, Cree, or German, Note that the language names.CAN.contain spaces. All of the data items on a each line are separated by commas, Database Format Your function should opon the file given as a parameter and read the data from it into a database. The keys for this database will be neighbourhood names, and the values will be records die another dictionary) for the matching neighbourhood. First, the read citydata() function should create an empty dictionary to be the overall database Then, for each neighbourhood from the input file, create one record the one dictionary with the following ficids • The neighbourhood’s name, as a string . The ward, as a string . The spoken languages, as a list of strings This record should then be added to the database, using the neighbourhood’s name as a key Once all of the records have been added the function should return the database dictionary. Evaluation Show transcribed image text o page Deportes UNIVERSITY OF SASKATCHEWAN CMPT 141 Na 2009 Question 1(6 points): Purpose: To practice the concept of dictionary as a database Degree of Difficulty: Moderate. Before starting this question first download the data file CityData.txt from the class Moodle. Make sure to put it in the same folder as your as.py python code Write a function called rond.citydata that takes as parametorisk • a string indicating the name of a city data file This function should return a database e, a dictionary of dictionaries) that stores all of the City data in a format that we will describe further below. You can review section 11.19 of the text for a refresher on what databases look like using dictionaries Input File Format The data file for this question looks like this: Holiday Park, Ward 2.Spanish, English, French Ukrainian Cree, German North Park, Ward 1, Tagalog, Ukrainian, French, German, English Each line of the file contains all of the data for a single neighbourhood. The first item on the line is always the neighbourhood’s name names are guaranteed to be unic . The second item is always the neighbour hood’s ward, which in the example above is Ward 2 Following that are one or more languages which are spoken in that neighbourhood. So there are residents in Holiday Park that speak Spanish. English, French Ukrainian, Cree, or German, Note that the language names.CAN.contain spaces. All of the data items on a each line are separated by commas, Database Format Your function should opon the file given as a parameter and read the data from it into a database. The keys for this database will be neighbourhood names, and the values will be records die another dictionary) for the matching neighbourhood. First, the read citydata() function should create an empty dictionary to be the overall database Then, for each neighbourhood from the input file, create one record the one dictionary with the following ficids • The neighbourhood’s name, as a string . The ward, as a string . The spoken languages, as a list of strings This record should then be added to the database, using the neighbourhood’s name as a key Once all of the records have been added the function should return the database dictionary. Evaluation

Expert Answer


Answer to o page Deportes UNIVERSITY OF SASKATCHEWAN CMPT 141 Na 2009 Question 1(6 points): Purpose: To practice the concept of di…