Question: Okay, so I've been tweaking this code that someone on here answered so that it works, but it doesn't. It keeps saying that the classes
Okay, so I've been tweaking this code that someone on here answered so that it works, but it doesn't. It keeps saying that the classes are unaccessible and I haven't even gotten to work on the other problems. It's for Python, and here's what the code is suppose to do:

And then here's what I got: (edited I added the code to copy)
Class Assignment:
class Assignment:
name = "" date = 0 grade = 0.0
def __init__(self, name, date, grade): self.name = name self.date = date self.grade = grade
def get_grade(self): return self.grade
def set_grade(self, grade): self.grade = grade
def add_assignment(self, assignment): self.assignments.append(assignment)
def __str__(self): return print(f'Name: {self.name}' \ f' Date: {self.date}' \ f' Grade: {self.grade}')
The Student class:
from assignment import Assignment
class Student:
name = ""
def __init__(self, name): self.name = name
def calculate_letter_grade(self): average_grade = self.calculate_average_grade() if average_grade >= 85: return print("A") elif average_grade >= 70: return print("B") elif average_grade >= 60: return print("C") elif average_grade >= 50: return print("D") elif average_grade >= 40: return print("F") else: return print("F")
def calculate_average_percentage(self): percentage_avg = sum[assignment.get_grade() for (assignment in self.assignments)/(len(self.assignments))] return percentage_avg
def calculate_average_grade(self): average_grade = sum(([assignment.get_grade() for assignment in self.assignments]) / len(self.assignments)) return average_grade
def get_assignments(self): # return self.assignments
def __str__(self): return print(f'Name: {self.name}' \ f' Average Percentage: {self.calculate_average_percentage():.2f}% ' \ f'Average Grade: {self.calculate_letter_grade()}')
And here's Class class:
from assignment import Assignment from student import Student
class Class:
name = "" List_Students = []
def __init__(self, name, students): self.name = name self.students = []
def add_student(self,student): self.students.append(student)
def write_to_file(self, ClassList.txt): ClassList = open(ClassList.txt): write(' {self.name} ') write(' List of students ') for idx, student in enumerate(self.students): write('Student {idx}: {student} ') for idx, assignment in enumerate(student.get_assignments()): write('\tAssignment {idx}: {assignment} ') write(' ')
def __str__(self): print('Class Name: {self.name} Students: {self.students}')
I don't really have much on main, so I didn't think to include it.
Week 12 -- Assignment We're building! Well, we're rebuilding. Let's look at the grading app for Mid-terms. We're going to rework it. For this assignment you must: Create a student class: Store a name Store a list of assignments Override init to take a name Override str to output the name, average assignment percentage, letter grade to match that average Calculate the student's average grade Create an assignment class: Store the assignment name Store the assignment date Store the assignment grade Override init to take a name and date Override str to output the name, date, and grade of the assignment Create a class class: Store a list of students Store the name of the class Override init to take the class name override str to output the class name, and its list of students Be able to write the class name, list of students, and their assignments to a file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
