Define a function that receives a dictionary. The dictionary…

Define a function that receives a dictionary. The dictionary keys are associated with a list of int. This function must return a dictionary of those keys but the associated value will be the max of the odd numbered entries, and the min of the even numbered entry. For example, for the first entry, the value is the max of the list. The second entry key, we use the minimum of the list. Here’s an example ‘abc’ : [2,6,4] 

In this test, each numbered part earns credit separately fro…

In this test, each numbered part earns credit separately from the others. We have a data file that contains data in a number of rows. Each row is expected to be made of 2 items separated by a tab.First item is an int number representing age, and second item is a social security number.Here’s an example:45    123-45-6789 We need to read the data into a python dictionary list, then do some clean up and plot the data. Write code as detailed below. Your code must follows the specs and restrictions shown below to be valid. 1. In the main function:  (5 points) ask the user for a file name. pass the filename to a function that will return a list of dictionary items. This function will return a global counter. If the counter is not 0, print the number of errors shown in that counter. Reset the counter back to 0. This counter is a global variable.  the dictionary list is then passed to a function that creates a plot objects list.  The plot objects list is is then passed to another function to save each object into a file. if no runtime error occurs from the above, print a success message, else print an error msg. 2. The function to read the data, will receive a file name then reads the data from the file one line at a time.  (5 points) For the sake of this function you are only allowed to import the regular expression module we learned about. No other import is allowed. Once one line has been read into your code, using a regex expression, collect the social security number (SSN), this will be the key.   If the SSN is unique, create an entry in the dictionary list being created, where the SSN is the key and a list follows that contains the age we just read from that line. Otherwise, if the SSN is not unique, add the age to the list of ages of the current line. For example, if 123-45-6789 appears in the file twice, the dictionary entry should be ‘123-45-6789’:[24 , 56] where 24 is the age of the first time we read that SSN and 56 is the age of the second time we read that SSN. Once all lines have been processed, return the dictionary list. If an entry has an invalid data such SSN or the integer value is not int or negative, then count by 1. The counter should be a global variable. return the dictionary list at the end. 3. Once we obtain the dictionary list from the function of the step above, the data will be passed to the plotting function which creates plots as follows:  (5 points) Using matplotlib, create a line plot where the SSN is the x-axis, and the y-axis is the max age of the list of each SSN. Save this object into a plot list that we will return later. Next create a piechart using matplotlib. The segments represent how many SSN’s max age falls into 0-25, 26-40, 40-60, 60-120. Note this function uses the max of the age list. Do not repeat the code that calculates the max of each SSN. Instead write a function that returns that value for use in both plots. return the plot object list. 4. The plotting function will return a list of plots to main. The main function will pass them to another function that processes the plot list as follows:  (5 points) Ask the user for a filename for each plot, then save the plot object in the list with that filename. Repeat the above for every object in the list.

Define the main function then call it. It should perform the…

Define the main function then call it. It should perform the following: Ask the user for a database filename, let’s call it myfile. Pass the filename to the function of question 1. The resulting dictionary should be saved in a variable, let’s call it DBdict. Pass DBdict to the list processing function. The returned dictionary should be saved in DBdict2. Extract the keys and values of DBdict2 into two lists of DBstr and DBint. Pass myfile, DBstr and DBint to the function of question 3. If the returned result is True proceed to the next step, else display an error message.  Pass the two lists DBstr and DBint to the plotting function you defined above. In the above step, you got a plot object. Display it then ask the user if they want to save, and save it as requested, or skip.

Now we process the dictionary and add its content to a sqlit…

Now we process the dictionary and add its content to a sqlite3 database. Write a function to receive a dictionary, then perform the following: Connect to a sqlite3 file named Cool to do the rest of the items below.  A table named tableP already exists where each record is represented by an alphanumeric values, p1 p2 p3 and p3. Add each dictionary entry to the table using a sql command as follows: Use a for loop to add an entry to the table only if the email ends with .edu When done print the number of all rows that were aded using a SQL command (count). Without using an if statement, if any of the code in this function causes any type of error, return a false value. If all the records are added correctly, print the total number of changes made using a sqlite3 python function. Return a true value. Ensure to apply all the changes and close all open connections.