NameError: name 'addition' is not defined
<p>I am getting <code>NameError: name 'addition' is not defined</code> while running following code</p>

<pre><code>class Arithmetic:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def addition(self):
        c = a + b
        print"%d" %c

    def subtraction(self):
        c=a-b
        print "%d" % c

add = addition(5, 4)
add.addition()
</code></pre>

<p>If you want to use your 'addition' method, you first need to instantiate an Arithmetic() object and use dot notation to call their functions. Make sure you properly indent your code because not only is it breaking a lot of PEP 8 rules but it just looks plain messy. In your first definition, don't forget you have to type <strong>__init__</strong> not <strong>init</strong>. Here's the code which should be applied:</p>

<pre><code>class Arithmetic(object):

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def addition(self):
        c = self.a + self.b
        print c

    def subtraction(self):
        c = self.a - self.b
        print c


a = Arithmetic(5, 4)
a.addition()
a.subtraction()
</code></pre>

python