Python Student Gradebook
class StudentPractice

Store a name, three scores, print the average

A class keeps related data together. average() is a method that uses self.scores.

Picture this: object then method

Construct the student, then ask for the average.

Student(...)object
→
self.scoreslist
→
average()mean

In easy words

The object remembers the name and scores. You do not pass them into average() again — self already has them.

Where this is used

School SIS software, LMS gradebooks, and any record that has fields plus calculations.

Run algorithm

Each step highlights the matching Python line. Program output appears only when a line that prints actually runs.

Ready
1class Student:
2def __init__(self, name, scores):
3 self.name = name
4 self.scores = scores
5def average(self):
6 return sum(self.scores) / len(self.scores)
7print(f"{s.name} {s.average()}")
Output:

Example Program

1class Student:
2def __init__(self, name, scores):
3 self.name = name
4 self.scores = scores
5def average(self):
6 return sum(self.scores) / len(self.scores)
7name = input()
8scores = list(map(int, input().split()))
9s = Student(name, scores)
10print(f"{s.name} {s.average()}")