Write a Python program to display student marks from the record

Introduction

Student records are a valuable resource for teachers and students. They can be used to track student progress, identify areas for improvement, and provide feedback to students.

Python is a powerful programming language that can be used to create a variety of applications, including student record management systems. In this blog post, we will show you how to write a Python program to display student marks from the record.

Step 1: Define a class to represent a student record

The first step is to define a class to represent a student record. This class will contain the student's name, roll number, and marks in each subject.

Python
class StudentRecord:
    def __init__(self, name, roll_number, marks):
        self.name = name
        self.roll_number = roll_number
        self.marks = marks

Step 2: Create a list of student records

Next, we need to create a list of student records. This list will contain the student records that we want to display.

Python
student_records = [
    StudentRecord("John Doe", 12345, [80, 90, 70]),
    StudentRecord("Jane Doe", 67890, [95, 100, 85])
]

Step 3: Write a function to display student marks

We can now write a function to display student marks. This function will take a list of student records as input and print the marks of each student to the console.

Python
def display_student_marks(student_records):
    for student_record in student_records:
        print(f"Name: {student_record.name}")
        print(f"Roll number: {student_record.roll_number}")
        print(f"Marks: {student_record.marks}")

Step 4: Call the function to display student marks

Finally, we can call the function to display student marks.

Python
display_student_marks(student_records)

Output

Name: John Doe
Roll number: 12345
Marks: [80, 90, 70]

Name: Jane Doe
Roll number: 67890
Marks: [95, 100, 85]

Additional considerations

  • You can modify the function to display student marks in a more specific format. For example, you could display the average marks of each student, or you could display the percentage of students who passed a particular subject.
  • You could also modify the function to allow the user to search for student records based on the student's name, roll number, or subject.
  • You could use the function to create a student report card.

Conclusion

Writing a Python program to display student marks from the record is a simple task. By following the steps outlined in this blog post, you can create a program that can be used to display student marks in a variety of ways.

Post a Comment

0 Comments