<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def degree(self, degree_number, direction='a'):
 """Return the asked scale degree. The direction of the scale is 'a' for ascending (default) and 'd' for descending. """

        if degree_number < 1:
            raise RangeError("degree '%s' out of range" % degree_number)
        if direction == 'a':
            notes = self.ascending()[:-1]
            return notes[degree_number-1]
        elif direction == 'd':
            notes = reversed(self.descending())[:-1]
            return notes[degree_number-1]
        else:
            raise FormatError("Unrecognised direction '%s'" % direction)