Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation Lab Assignment 1 Continental Data Computation Due Date (a two-week LA) Sections(540,543,544,545) 1/28/22 @ 11:59pm

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation Lab Assignment 1 Continental Data Computation Due Date (a two-week LA) Sections(540,543,544,545) 1/28/22 @ 11:59pm Concepts Review of CS1110 Concepts such as basic data structures, control flow structures, and functions in Python Use flow chart to design a function Problem Specification Your program is to calculate the continent information based on an input file. Each input file contains the meta-information in the following order. 1) Name_of_country 2) Population_of_country 3) Area_of_country 4 Main_language 5) Continent For example, the data short.txt as input looks like: Latvia, 1991400, 64553, 1v, Europe South Sudan, 11184391,619745,en, Africa Feypt,87668300,1000450, ar, africa Guinea-Bissau, 1746000, 6125.pt Africa Zimbabwe, 1.3861239,390757, en Africa kali,1576000, 124813, fr, Africa Portugal, 1847,9.2008,pt, rope Now Zealand, 4547900,270467,6, Oceania Croatia,4267558.56594, hr, Europe Nauru, 1884,21, en, Oceania Estonia, 1515819,45227,45,ture Libya, 625.3000, 1754640, ar,Africa Sierra Leone, 6205000,71745, Africa Denmark, 5655759,41094,da, furope Tuvalu, 1129,2, n,Oceania Chad, 13211000, 1284000, Fr, Africa Tonga, 103252,147,,Oceania Niger, 17338787,1257000, fr, Africa Benin 990068, 112622.fr, Africa Penguin Land,6,14200000, penguin_language, Antarctica CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation You take in the whole input file in .txt format and print the desired output in the console. You need to parse each line for the given txt file and find out the total population, total area, languages spoken for each continent that must be sorted. The output should contain the metainformation in the following order: 1) Name of Continent: String 2) Population: int 3) Area: int 4) List of All Languages: list of String 5) Most Spoken Language: String The output for data short.txt is as follows: Lihat file do you want to parse?: data_short.txt Name of Continent: Africa Population: 182423507 Area: 7784171 List of All Languages: ['ar", 'en', 'fr", "pt") Most spoken language: fr Name of Continent: Antarctica Population: @ Area: 14200000 List of All Languages: ['penguin_language'] post spoken language: penguin_language Name of Continenti Europe Population: 23708727 Areal 301564 List of All Languages: ['pt', 'lv', 'hr', 'et', 'da'] Most spoken language pt Name of Continent: Oceania Population: 4672559 Area: 271261 List of All Languages: ['en'] lost spoken language: en Name of Continent is the name for each continent. In the console, the name shall be sorted. Population is the total population of each continent. Area is the total area of each continent. List of all languages is the collection of all languages spoken in that continent Most spoken language is the language spoken by most countries in the continent. For instance, let's take an eample of the continent Africa in data_short.txt and manually find out its most Spoken language CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation South Sudan, 11384393,619745,en, Africa ---> en Egypt,87668100,100245e, ar, Africa Guinea-Bissau, 1746600, 36125,pt, Africa pt Zimbabwe, 13051239,39e757,en, Africa Mali,15768000, 1248192,fr, Africa Libya, 6253000, 175954e, ar, Africa Sierra Leone,6285600, 71740, en, Africa Chad, 1321100e, 1284eee,fr, Africa fr Niger, 17138707,1267600, fr, Africa fr Benin,9983068,112622.fr, Africa en has occured 1 times er has occured 2 times pt has occured 1 times fr has occured 4 times fost spoken Language: fr If you build your own split function without using python's split, that also counts towards your extra credit, 10 points How to Test We have provided two test files, i.e., data_short.txt and data_short2.txt. The output for data short.txt should look like the following in your console: Nhat file do you want to parse?: data_short.txt Name of Continent: Africa Population: 182423507 Area: 7784171 List of All Languages: ['ar', 'fr', 'en', 'pt'] Most spoken language: fr Name of Continent: Antarctica population: @ Area: 14200000 List of All Languages: ['penguin_language'] Most spoken language: penguin_language Name of Continent: Europe population: 23708727 Area: 301564 List of All Languages: ['lv', 'da', 'hr', 'pt', 'et'] Most spoken language: lv Name of Continent: Oceania population: 4672559 Area: 271261 List of All Languages: ['en'] Host spoken language: en The output for data_short2.txt should look like the following in your console: CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation What file do you want to parse?: data_short2.txt Name of Continent: Americas Population: 439276773 Area: 14314305 List of All Languages: ["nl', 'en', 'es'] Most spoken language: es Name of Continent: Asia Population: 1594366325 Area: 12955456 List of All Languages: ['dz', "bn" Most spoken language: ar Name of Continenti North Pole populationi @ Area: see List of All Languages: ['extinct_penguin_language ] Most spoken language: extinct_penguin_language Once the find the correct output for data_short.txt and data_short2.txt, finish up your work by doing the same for data.txt. The data.txt is a larger file with five continents. Design Requirements Basic Structure Your code should be designed in a similar fashion to the following template. A more detailed template has been given to you in the assignment folder. import sys def unique_regions(list_of_all_countries_with_data) 1955 of population_count_for_a_region region, list_of_211_countries_with_data): def ares_count_for_a_region(region, list of all countries_with_data): pas def list_of_all_languages (region, list_of_all_countries_with_data): pes file_name-input"What file do you want to parsel: "> try with open(File_sane) as my_file: list_of_all_lines - my_file.readlines() excepti print("File not found.') sys.exit() Your code here. Mere you call the necessary funct and it everything as needed CS 1120 (Python) - Spring 2022 LA1 Continental Data Computation Flowchart You must design a flowchart for each function to illustrate how function is designed. Also, you need to design a flowchart to show how the drive code is designed in terms of how inputs are received, and the functions are called Implementation Phase Using the pseudocode developed, write the Python code for your assignment. This is a two- week assignment Testing Phase Another data_short2.txt is given to you with its output. The output should match exactly. Build your program incrementally, carefully testing each function as you go Grading You can earn about 110 points in this assignment. The 10 points counts towards your extra credit. A correct program with correct output, with proper use of all the function is worth 100 points. If you chose to not use python's split and build your own split function you will eam extra 10 points. Assignment Submission Generate a .zip file that contains all your files including: o Program Files Any input or output files o Flowchart Submit the zip file to the appropriate folder on E-Learning

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions