Python calling function with return statement
<p>I have the below piece that created few person objects and apply some methods on those objects.</p>

<pre><code>class Person:
    def __init__(self, name, age, pay=0, job=None):
        self.name = name
        self.age  = age
        self.pay  = pay
        self.job  = job

    def lastname(self):
        return  self.name.split()[-1]

    def giveraise(self,percent):
        return self.pay *= (1.0 + percent)

if __name__ == '__main__':
    bob = Person('Bob Smith', 40, 30000, 'software')
    sue = Person('Sue Jones', 30, 40000, 'hardware')
    people = [bob,sue]
    print(bob.lastname())
    print(sue.giveraise(.10))
</code></pre>

<p>Once I run this program, this is the output--</p>

<p>Syntax Error: Invalid syntax</p>

<p>but when I run using the below code, I  don't have any problem,</p>

<pre><code>if __name__ == '__main__':
    bob = Person('Bob Smith', 40, 30000, 'software')
    sue = Person('Sue Jones', 30, 40000, 'hardware')
    people = [bob,sue]
    print(bob.lastname())
    sue.giveraise(.10)
    print(sue.pay)
</code></pre>

<p>What is the difference in two cases</p>
