IT-209-Assignment 1 (A1) - Reviewing and Exercising Python Capabilities IT209 - Lab Assignment 1 (LA1) Assignment Given: Lab #1,01/31/2023 Lab Assignment Due: end of Lab or at the discretion of the GTA Complete Class Assignment (A1) Due: 02/09/2022,11:59pm This assignment serves as a review of several important Python features and capabilities you learned in the previous course. In it you will create code to do the following (parentheses indicate which part of the assignment is due in Lab I, LAl, and which is due later as part of the class assignment A1): 1. read a file of U.S, state information from a text file (L.A I) 2. create a Python two dimensional list, or list-of-lists, from the info in the file (LAI) 3. display each item in the list (LA1) 4. build a dictionary from the state list consisting of the state abbreviation as key, and a list of [state name, state capital, and state population] as the associated itcm (A1) 5. create an output text file and write each state item to from the dictionary by iterating through the it and writing the state name, capital, and population in comma-separated fomat, with each state being on its own separate line (AI) Note that the above are to be implemented as separate functions. The "file read" and "list create", items 1 and 2 , should be implemented as one function, but items 3,4 , and 5 should each be implemented as a function. resulting in a total of four that you are to create. This lab assignment requires you to complete items 1,2 , and 3 above by creating two functions, and is worth a total of up to 10 points. Items 4 and 5 are to be completed as part of Assignment i ( A 1) by creating the other two required functions, and is worth up to 20 points. So this assignment counts for both the finst lab and the first part of the first programming assignment. Use the time in the lab to help complete part of it. Input File You will be provided with an input file consisting of U.S. state information. The file name is "stateinfo7,txt". Each line consists of items separated by a semi-colon ( (;,7) state abbreviation, full state name, state capital, and state population. All of these will be read in as string types and don't need to be converted. Part of the input file is shown below. The actual file has additional lines. AL; Alabama; Montgomery; 4447100 AK; Alaska; Juneau; 626932 AZ; Arizona; Phoenix; 5130632 AR; Arkansas; Little Rock; 2673400 CA; California; Sacramento; 33871648 CO; Colorado; Denver, 4301261 CT: Connecticut; Hartford; 3405565 DE; Delaware; Dover; 783600 DC; District of Columbia; Washington; 572059 FL; Florida; Tallahassec; 15982378. GA; Georgia; Atlanta; 8186453 Functions The separate functions to be implemented should be such that the global code is minimized. With most of the program's action being handled by the functions the global code could be approximately this small: \# Lab I (LAl) code stateList = loaditems( \# invoke function to read the file into a list, return the statelist displayltems(stateList) \#takes list as input and prints it (this should be simple) \#Assignment \#1 (A1) code SD= buildDict(stateList) \# builds and returns the dictionary SD built from the stateList writeFile(SD) \# creates output file and writes SD records to it The above shows suggested function names, but you may create your own. The Lab requires you to create 'loadltems' and 'displayltems'. 'loaditems' reads the input file, splits items on each line into their own strings, places those items in a list, then appends that to a master list. The result is a 'list of lists', or two dimensional list, and is returned and saved in 'stateList' above. The 'stateL List' list of lists (or 2 dimensional list) will therefore look like this: [ [AL:, 'Alabama', 'Montgomery', "4447100'], ['AK', 'Alaska', 'Juneau, '626932']. ['AZ', 'Arizona', 'Phoenix', '5130632']. ['WY', 'Wyoming", 'Cheyenne', '483782'] ] Cleaning the Input Data When reading the state data from the input file be sure to: 1. Only add lines that have actual data - sometimes there are blank lines, especially at the end of the file, often just extra newline ('In') eharacters. To do this cheek the length of each input line. If the line length is greater than 4, you may assume it has actual data. 2. Split the data into its own parts using the split O method: abbreviation, name, capital, population using split and a semi-colon (";") as the separator 3. Remove extruneous blanks from the start and end of each data item using the strip 0 method 4. Remove the ' n ' newline character from the end of the input line Displaying the Input Data 'displayltems(stateList)' iterates through the list parameter and prints out each item on a separate line. The string 'format' method is used to produce neat uniform columns. The output should look like this: Doing the above fulfills the Lab I requirement. The following is required to complete Programming Assignment \#1 (A1). Dietionary The 'buildDict( )' function reads each inventory item from the statel ist list and builds a dictionary consisting of the state abbreviation as the key, which is the first item in each states list. The associated value is a list consisting of the state name, capital, and population. For example, the dictionary item for Alabama would be: {AL:[Alabama,Montgomery","4447100]} The function returns SD, the complete dictionary, which will have one entry like the above for each state. Output File The output file is a text file consisting of comma-separated data. The file name you create is "IT209_A loutput.txt". There is one line per data item. Each line consists of (1) state name, (2) state capital, and (3) population. Build the file by iterating through the dictionary, which is supplied as a parameter to the function, and writing one line with the individual items on it, separated by a comma. Do not write the list itself to the file. Sample output file lines are show below as they would appear when viewing using Notepad: Alabama,Montgomery, 444710 Alaska,Juneau,62693 Arizona,Phoenix, 513063 Arkansas,Little Rock, 267340 California,Sacramento,3387164 Colorado,Denver,430126 Connecticut,Hartford,340556 Delaware,Dover, 78360 District of Columbia, Washington, 57205 Florida,Tallahassee, 1598237 (etc.) What and where to submit: 1. Submit by uploading two files: the python file containing the Python code, and the sereenshot of output (only for LA1) or the output text file you generate (only for A1), to Blackboard. 2. For the lab portion, name the submitted file:_-lastname>_LA1py. For example: mary_smith_LA1.py. 3. For the class assignment portion, name the file: _ _Al,py. 4. For both, include a short set of comments as the first lines that identify the program, its purpose, and its author. How the assignment will be assessed The Python code will be visually inspected and executed via command line ("python sprogram name>py") or double-clicking it from a Directory. The GTA will nun it with a sample input file and verify comect execution