Classfilter by class tools add new student
Here is an example of how you can use the ClassFilter
class to add a new student to a class:
from classfilter import ClassFilter
# Create a new ClassFilter object
cf = ClassFilter()
# Define the class and student information
class_name = "Math 101"
student_name = "John Doe"
student_id = "12345"
student_grade = "A"
# Add the student to the class
cf.add_student(class_name, student_name, student_id, student_grade)
# Print the updated class roster
print(cf.get_class_roster(class_name))
This code creates a new ClassFilter
object, defines the class and student information, and then adds the student to the class using the add_student
method. Finally, it prints the updated class roster using the get_class_roster
method.
You can also use the add_student
method to add multiple students to a class at once:
cf.add_students(class_name, [
{"name": "Jane Doe", "id": "67890", "grade": "B"},
{"name": "Bob Smith", "id": "34567", "grade": "C"}
])
This code adds two new students to the class using a list of dictionaries, where each dictionary represents a student with their name, ID, and grade.
You can also use the update_student
method to update the information of an existing student:
cf.update_student(class_name, student_id, {"grade": "A+"})
This code updates the grade of the student with the specified ID to "A+".
You can also use the remove_student
method to remove a student from the class:
cf.remove_student(class_name, student_id)
This code removes the student with the specified ID from the class.
You can also use the get_student
method to retrieve the information of a specific student:
student_info = cf.get_student(class_name, student_id)
print(student_info)
This code retrieves the information of the student with the specified ID and prints it.
You can also use the get_class_roster
method to retrieve the entire class roster:
roster = cf.get_class_roster(class_name)
print(roster)
This code retrieves the entire class roster and prints it.
Note that the ClassFilter
class is just a simple example and you may want to add more features and functionality to it depending on your specific use case.