Question: In python, please let the code be original and genuine Nunavut,35000,1 Alberta,4067000,34 Saskatchewan,1098000,14 Yukon,35000,1 Manitoba,1278000,14 British Columbia,4648000,42 Ontario,13448000,121 Quebec,8164000,78 Prince Edward Island,142000,4 Newfoundland,519000,7 Northwest Territories,41000,1
In python, please let the code be original and genuine

Nunavut,35000,1 Alberta,4067000,34 Saskatchewan,1098000,14 Yukon,35000,1 Manitoba,1278000,14 British Columbia,4648000,42 Ontario,13448000,121 Quebec,8164000,78 Prince Edward Island,142000,4 Newfoundland,519000,7 Northwest Territories,41000,1 Nova Scotia,923000,11 New Brunswick,747000,10
Download the file provincial_seats.txt from the course Moodle. The file looks like this: Nunavut , 35000, 1 Alberta , 4067000,34 Saskatchewan , 1098000, 14 Yukon , 35000, 1 Each line consists of a province or territory's name, its population (rounded to the nearest thousand) and its number of seats in the government, all separated by commas. Write code to open this file and read this data into three separate lists (one for the names, one for the populations, and one for the seats). Then, convert each list to a numpy array using the array() method from numpy. Make sure to maintain the order so that the lists line up by position (ie. Nunavut is first in the array of names, and its matching population and seats are the first items in their respective arrays). Test these arrays before you move on! You will use them to perform all the following array calculations. Predicted Seats Using array operations on the loaded data, create an array that contains, for each province, the expected number of seats that each province WOULD have if its seats were exactly proportional to its population. Round these values to the nearest integer (you can use numpy's around () method). Hint: As part of this calculation, you'll probably need Canada's total population, and the total number of seats. Think about how you can get these using the data you already have using numpy's.sum() method. Page 4 UNIVERSITY OF SASKATCHEWAN Department of Computer Science 178 Thorvalding 110 S SSK SINS. The New CMPT 113/141 Winter 2021 Introduction to Computer Science Finding Over- and Under-represented provinces If a province has more actual seats than the number of seats you calculated based on its population above we'll call that province over-represented. If it has fewer actual seats than predicted seats, then it is under- represented. Use array relational operators and logical indexing to create three arrays for. the names of the over-represented provinces . the expected seats of those provinces the actual seats of those provinces Then do the same thing for the under-represented provinces. Finally, print your results to the console. You can use loops for this final task. Sample Run The output of your program might look something like this: Based on population, the following provinces are over-represented: Nunavut Expected: 0 Actual: 1 Saskatchewan Expected: 11 Actual: 14 Yukon Expected: 0 Actual: 1 Manitoba Expected: 12 Actual: 14 Prince Edward Island Expected: 1 Actual: 4 lleu foundland Expected: 5 Actual: 7 Northwest Territories Expected: 0 Actual: 1 Nova Scotia Expected: 9 Actual: 11 Neu Brunswick Expected: 7 Actual: 10 The following provinces are under-represented : Alberta Expected: 39 Actual: 34 British Columbia Expected: 45 Actual: 42 Ontario Expected: 129 Actual: 121 Quebec Expected: 79 Actual: 78 What to Hand In
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
