Question: Please provide code in Python: Build the dictionary Prompt the user for a file name that contains information about a student and their scores in
Please provide code in Python:
Build the dictionary
Prompt the user for a file name that contains information about a student and their scores in a class. The prompt for the CSV file should be: Enter the CSV file: with a space after the colon and no newline.
The csv file will contain the students firstname, lastname, PID, and a list of scores they have earned in a class. The CSV file contains a header row that indicates what each column represents.
You will need to read in the information from the csv file and create a dictionary of all the students and their scores. The dictionary will have the students PID as a key, and each entry will be a list which contains the remaining information for that student lastname firstname, and all of the scores, in that order
Once you have created the dictionary, you should print it out so you can see what it looks like and that it looks correct.
Write the findFirstname function
This function will have parameters, a dictionary and a string. The main program will prompt the user for a first name using the prompt Enter a firstname: again space after colon, no newline and then call the function with the dictionary and the firstname. The function should print the firstname and lastname of all students who have that firstname. This function does not return anything. If no one with that firstname is in the dictionary, the function does not print anything.
Write the getAvgScore function
This function will have two parameters, a dictionary and a string representing the student PID. The main program will prompt the user for the PID using the prompt Enter a PID:, then call the function with the dictionary built in step and the PID. The function should return the average of all of the scores from the student with that PID. If the PID given is not in the dictionary, the function will not print anything, but should return an average of The average for the student should be printed by the main program, NOT from within the function.
A sample file you can practice with is StudentGrades.csv
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
