During this lab, you will create and hand in 1 file:

• grade_calculator.py - This part may be completed in pairs if you wish.

### Background scenario

You’ve just recently realized your dream of becoming a high school teacher. After your first semester on the job, you realized keeping track of student grades and calculating overall letter grades from various scores takes too time to do manually. While reminiscing fondly over your days in CS301, you realize you can make the computer do a lot of this work for you!

### Program requirements

Your program will repeatedly prompt a user for a command. The commands:

1. Get the student name, exam 1 score, exam 2 score, and exam 3 score.
2. [OPTIONAL] Do some checking to make sure these things are valid, print error if not.
• Score must be a value between 0 and 100.
2. Modify an existing student's score
1. Get the student's name, exam number to modify (1, 2, or 3) and new score.
2. [OPTIONAL] Do some checking to make sure these things are valid, print error if not.
• Name must be in gradebook.
• Exam number must be 1, 2, or 3.
• Score must be between 0 and 100.
3. If valid, appropriately change the information stored in the gradebook.
3. Retrieve all entries, calculate letter grade, and print
1. Calculate the mean and standard deviation of the class population.
2. Compare each student's exam score sum to the mean and standard deviation to assign a letter grade for that student.
• If sum of student's scores is greater than or equal to the mean plus one standard deviation, the grade should be A.
• Otherwise, if the sum is greater than or equal to the mean, the grade should be B.
• Otherwise, if the sum is greater than or equal to the mean minus one standard deviation, the grade should be C.
• Otherwise, the grade should be F (there are no Ds).
3. Print the following information (follow sample run):
• Mean
• Standard Deviation
• For each student: name, exam 1 score, exam 2 score, exam 3 score, letter grade. (Note: the order of students does not matter, as long as all student information is present.)
4. Quit the program

One additional specific requirement: you must implement this by using a single dictionary object.

### How do we approach this?

#### Skip this section at your own risk - there are very good suggestions here!

The general structure is very similar to some past programs. Get a command from a user, execute the command, repeat, and so on. Infinite loop (until the command entered is quit). That’s simple enough.

How do we store the information, though? We are talking about storing a set of scores and keeping them associated with names. This doesn't sound like the job for a list, because it has no notion of association. How about a dictionary? Yes, sounds just right!

It's straightforward if we want to store one score (a float) per name. The key of each entry would be the name (a string) and the value would be the score (float). However, we want to store multiple scores per name. How do we do this? We put the scores in a list first. Thus, each entry of our dictionary has the name (a string) as the key and a list of scores as the value.

One other recommendation is to separate your program into a main section (the loop and input) and functions. This will make it easier for you to read, understand, and modify your code later on. If you choose this approach, then you need to consider how the functions see your dictionary object, which you should declare in the beginning of your main section (outside of all functions). You could consider just referring to it as a global variable inside your functions, but this is often messy so our recommendation is to pass the gradebook into your functions as an argument.

For example, let's say we decide to define a function which we will call to add a new entry to the gradebook. Our function header would be something like def addNewStudent(gradebook, name, score1, score2, score3) – the important thing to notice is that we are passing our dictionary object as the first argument into this function, thus inside that function we can refer to it and modify it, just like lists.

One other note: this lab requires calculating the mean and standard deviation, similar to a previous lab. An important thing to note is that we are calculating the standard deviation of the population, so the formula is slightly different:

### Sample Run

Here's a full sample run for you to test against. User input in blue:

```Enter an action (add, retrieve, modify, quit): retrieve
Mean: None
Standard Deviation: None
Enter a name: Jill
Enter exam 1 score: 97
Enter exam 2 score: 94
Enter exam 3 score: 96
Enter a name: John
Enter exam 1 score: 84
Enter exam 2 score: 87
Enter exam 3 score: 82
Enter an action (add, retrieve, modify, quit): retrieve
Mean: 270.0
Standard Deviation: 17.0
Name: Jill, Exam 1: 97.0, Exam 2: 94.0, Exam 3: 96.0, Letter Grade: A
Name: John, Exam 1: 84.0, Exam 2: 87.0, Exam 3: 82.0, Letter Grade: C
Enter a name: Bill
Enter exam 1 score: 47
Enter exam 2 score: 83.23
Enter exam 3 score: 75
Enter an action (add, retrieve, modify, quit): retrieve
Mean: 248.41
Standard Deviation: 33.5398698069
Name: Jill, Exam 1: 97.0, Exam 2: 94.0, Exam 3: 96.0, Letter Grade: A
Name: John, Exam 1: 84.0, Exam 2: 87.0, Exam 3: 82.0, Letter Grade: B
Name: Bill, Exam 1: 47.0, Exam 2: 83.23, Exam 3: 75.0, Letter Grade: F
Enter an action (add, retrieve, modify, quit): modify
Enter a name: John
Exam number to modify (1, 2, 3): 3
Enter new score for it: 86.5
Enter an action (add, retrieve, modify, quit): retrieve
Mean: 249.91
Standard Deviation: 33.8111352466
Name: Jill, Exam 1: 97.0, Exam 2: 94.0, Exam 3: 96.0, Letter Grade: A
Name: John, Exam 1: 84.0, Exam 2: 87.0, Exam 3: 86.5, Letter Grade: B
Name: Bill, Exam 1: 47.0, Exam 2: 83.23, Exam 3: 75.0, Letter Grade: F
Enter an action (add, retrieve, modify, quit): quit```

For clarity, all prompts and output between main commands are indented two spaces. The order of students in the retrieve command does not need to match the order given here, but the per-student information (scores and grades) should follow this ordering.

As input checking is optional (for the last time!), you may handle invalid input in any way you see fit.