Project 6: Gradebook

Your professor needs help managing his grades for CS 141. He has asked you to write a gradebook application that will store a list of students along with their corresponding final course grades (which are integers).

You decide to design your program by using two lists that will always be the same length. One list, called names, will store the first names of the students. The second list, called grades, will store the grades. You decide to always keep the lists managed in such a way that the person whose name is in names[0] will always have their corresponding grade in grades[0], and the same thing for names[1] and grades[1], etc. In other words, the two lists are related to each other the same way as the english_words and pirate_words lists were related to each other in the pirate translator.

Functions

Write these functions first, and make sure they work:

Main program

Using your functions from above (you can define others if you want), write a main function that does the following steps. Read in the contents of the file gradebook.txt, and store the return values in lists called names and grades. Then print out a menu that lets the user choose from the following operations: The program should keep running until the user wants to quit.

Sample interaction

[program begins]
1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 2
All students:  ['phil', 'sally', 'mary', 'fred', 'joe']

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 3
All grades:  [90, 80, 95, 85, 89]

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 4
Look up which student? sally
Student sally has grade 80

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 4
Look up which student? jesse
That student doesn't exist.

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 1
New student name: jesse
New student grade: 99

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 5
The student with the highest grade is jesse
Their grade is 99

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 6
The student with the lowest grade is sally
Their grade is 80

1. Add a new student & grade
2. Print all students
3. Print all grades
4. Lookup a student's grade
5. Find student with highest grade
6. Find student with lowest grade
7. Quit
Choose an option: 7
Done.
[program ends]

Hints

For the highest/lowest grade, you will need to re-visit the code we wrote that finds the maximum or minimum element in a list. However, you need to find not only the element, but *its position*. That way, you can find the corresponding element in the names list. For instance, when you find the minimum item in the grades list, you'll find 80. However, you also need the *position* of the 80, which is 1, because names[1] is sally.

Challenge Problems

Add more features to the program. For instance, you could add a feature to print all the students who are getting an A (>= 90). Or print all the students who are failing. Or calculate the average grade in the class. Or something else.

What to turn in

Through Moodle, turn in your code as a file called gradebook_yourLastName_yourFirstName.py.