title: Pass a variable between functions within a class
body: <p>How can I pass a variable returned by a function within a class to another function within that class?<br>
  For example (implementing linear regression):</p>
  
  <pre><code>class ForwardPropagation(object):
      def __init__(self, xs, realoutput): 
          self.xs = np.asarray(xs)
          self.realoutput = np.asarray(realoutput)
          self.guess_slope = random.randint(1,10)
          self.guess_b = random.randint(1,10)
          self.guess_output = (self.guess_slope * self.xs) + self.guess_b
  
      def distance(self):#returns np.array with distance results
          abs_D = self.realoutput - self.guess_output
          D_sqr = abs_D ** 2
          return abs_D, D_sqr
  
      def error(self):
          sigma = np.sum(D_sqr)
          mean_error = sigma / len(D_sqr)
          return mean_error
  </code></pre>
  
  <p>How can I pass the variable D_sqr, which is the squared of my distance function, to the error function? </p>