Generation

class from descriptionWed, 15 Mar 2023

class to calculate gpa based on weighted value from credits and marks from user input

class GPA: def __init__(self): self.credits = [] self.grades = [] def addCourse(self, grade, credit): self.credits.append(credit) self.grades.append(grade) def calcGpa(self): total_credits = 0 grade_point = 0 for i in range(len(self.credits)): grade_point += self.grades[i] * self.credits[i] total_credits += self.credits[i] return grade_point / total_credits

Want to kickstart your project?Use the new AI Studio to create your code