lundi 30 septembre 2019

Creating and updating a Class with student information in Python

I want to design a class to store student data. Create a class named 'student' with the following attributes and methods:

Class student -- name -- GPA (0-4) -- number_of_courses (0-50) -- number_of_credits(0-120) -- init(self, name, GPA, number_of_courses, number_of_credits):

I want to add an additional definition called... -- add_course(self, grade, credits): This function will add a course to student records. To add a course I want it to add 1 to number_of_courses, add credits to the number_of_credits and calculate the new GPA.

I also want to add an additional function... -- print_student(self): that will print all attributes of a student

  • I want to create 100 students with random information and store them in a list.
  • Finally, I want to ask the user to choose one of the students to update (for example by entering a number between 1 -100). Then have them use the add_course function to add a course for that student. Finally, I want the program to print the student information before and after the update.

Here is my code thus far:

enter image description here




Aucun commentaire:

Enregistrer un commentaire