title: Passing variables between methods in Python?
body: <p>I have a class and two methods. One method gets input from the user and stores it in two variables, <code>x</code> and <code>y</code>. I want another method that accepts an input so adds that input to <code>x</code> and <code>y</code>. Like so:</p>
  <pre><code>class simpleclass(object):
      def getinput(self):
          x = input(&quot;input value for x: &quot;)
          y = input(&quot;input value for y: &quot;)
      def calculate(self, z):
          print(x + y + z)
  </code></pre>
  <p>When I run <code>calculate(z)</code> for some number <code>z</code>, it gives me errors saying the global variables <code>x</code> and <code>y</code> aren't defined.</p>
  <p>How can <code>calculate</code> get access to the <code>x</code> and <code>y</code> values that were assigned in <code>getinput</code>?</p>