Happy Birthday

In [1]:
def main():
    print("Happy birthday to you!")
    print("Happy birthday to you!")
    print("Happy birthday, dear Fred...")
    print("Happy birthday to you!")    
In [2]:
main()
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Fred...
Happy birthday to you!
In [3]:
def happy():
    print("Happy birthday to you!")
In [4]:
def main2():
    happy()
    happy()
    print("Happy birthday, dear Fred...")
    happy()    
In [5]:
main()
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Fred...
Happy birthday to you!
In [6]:
singFred = main2
In [7]:
singFred()
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Fred...
Happy birthday to you!
In [8]:
def singLucy():
    happy()
    happy()
    print("Happy birthday, dear Lucy...")
    happy()
In [10]:
singFred()
print()
singLucy()
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Fred...
Happy birthday to you!

Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Lucy...
Happy birthday to you!
In [12]:
def sing(person):
    happy()
    happy()
    print("Happy birthday, dear {0}...".format(person))
    happy()
In [13]:
sing
Out[13]:
<function __main__.sing>
In [14]:
sing()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-5e3bdb313197> in <module>()
----> 1 sing()

TypeError: sing() missing 1 required positional argument: 'person'
In [15]:
sing("Fred", "Johnson")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-15f9588de3a6> in <module>()
----> 1 sing("Fred", "Johnson")

TypeError: sing() takes 1 positional argument but 2 were given
In [16]:
sing("Fred Johnson")
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Fred Johnson...
Happy birthday to you!
In [17]:
sing("Lucille Ball")
Happy birthday to you!
Happy birthday to you!
Happy birthday, dear Lucille Ball...
Happy birthday to you!
In [ ]: