Is self prefix needed/suggested when you only need a temporary variable inside an instance method?

In the get_average method, self.scores is just a temporary list variable in this case, used to sum up all the scores.

class Student:
  def __init__(self, name, year): = name
    self.year = year
    # list of Grade objects, not scores!
    self.grades = []
  def add_grade(self, grade):
    if type(grade) is Grade:
      self.grades += [grade]

  def get_average(self):
    self.scores = [item.score for item in self.grades]
    return sum(self.scores) / len(self.scores)

class Grade:
  minimum_passing = 65
  def __init__(self, score):
    self.score = score

But if you dont need to access this value with respect to each instance (e.g. you don’t need Pieter’s list of scores) can you instantiate the variable without the self prefix, like this? If not, what are the reasons to avoid this?

def get_average(self):
    scores = [item.score for item in self.grades]
    return sum(scores) / len(scores)

scores should be a local variable (so without self), you don’t need this variable to pollute your scope.