Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Python program for Professor P. Create a class named Student that holds

ID: 3690673 • Letter: C

Question

Create a Python program for Professor P.

Create a class named Student that holds the following data about a student:

1. Name

2. Student ID number

3. GPA

4. Expected grade in this course

5. Full time or part time

Create five student objects from this class and pass data to fill in the class data above.

Besides creating the objects, you will write a menu-driven program that performs the following tasks:

1. Look up and print the student GPA

2. Add a new student to the class

3. Change the GPA of a student

4. Change the expected grade of a student

5. Print the data of all the students in a tabular format

6. Quit the program

Explanation / Answer

import students G
import pickle
FIND_GPA = 1
ADD_STUDENT = 2
CHANGE_GPA = 3
CHANGE_GRADE = 4
PRINT_DATA = 5
QUIT = 6
FILENAME = 'students_G.dat'
def main():
mystudents = load_students_G()
choice = 0
while choice != QUIT:
choice = get_menu_choice()
if choice == FIND_GPA:
find_gpa(mystudents)
elif choice == ADD_STUDENT:
add_student(mystudents)
elif choice == CHANGE_GPA:
change_gpa(mystudents)
elif choice == CHANGE_GRADE:
change_grade(mystudents)
elif choice == PRINT_DATA:
print_data(mystudents)
save_students(mystudents)
def load_students_G():
try:
input_file = open(FILENAME, 'rb')
students_labG_dct = pickle.load(input_file)
input_file.close()
except IOError:
students_labG_dct = {}
return students_labG_dct
def get_menu_choice():
print()
print("Menu")
print("------------------------------")
print("1. Look up and print a student's GPA")
print("2. Add a new student to the class")
print("3. Change the GPA of a student")
print("4. Change the expected grade of a student")
print("5. Print the data of all the students")
print("6. Quit the program")
print()
choice = int(input("Please enter your choice, 1-6: "))
while choice < FIND_GPA or choice > QUIT:
choice = int(input("Please enter a valid choice, 1-6: "))
return choice
def find_gpa(mystudents):
name = input("Enter a name: ")
if name in mystudents:
print(mystudents.gpa) ###TRYING TO FIND A WAY TO PRINT ONLY THE STUDENTS GPA. CAN'T FIND A WAY TO "GET" THE DATA FROM THE CLASS!
else:
print(mystudents.get(name, 'That name is not found.'))   
print()
def add_student(mystudents):
name = input("Enter a new student's name: ")
idn = input("Please enter the student's ID number: ")
gpa = input("Please enter the student's GPA: ")
grade = input("Please enter the student's expected grade in this course: ")
hours = input("Please enter if this student is full or part-time: ")
print()
entry = students_lab10.Students(name, idn, gpa, grade, hours)
if name not in mystudents:
mystudents[name] = entry
print("The entry has been added.")
print()
else:
print("That name already exists.")
print()
def change_gpa(mystudents):
name = input("Enter a name: ")
if name in mystudents:
gpa = input("Please enter the student's new GPA: ")
entry = students_labG.Students(name, idn, gpa, grade, hours)
mystudents[name] = entry
print("GPA updated.")
print()
else:
print("That name is not found.")
def change_grade(mystudents):
name = input("Enter a name: ")
if name in mystudents:
grade = input("Please enter the student's new grade: ")
entry = students_G.Students(name, idn, gpa, grade, hours)
mystudents[name] = entry
print("Grade updated.")
print()
else:
print("That name is not found.")
print()
def print_data(mystudents):
input_file = open(FILENAME, 'rb')
print(mystudents)
print()
input_file.close()
def save_students(mystudents):
output_file = open(FILENAME, 'wb')
pickle.dump(mystudents, output_file)
output_file.close()
main()