[Python #8] create e40.py
This commit is contained in:
parent
d9a5e0250e
commit
155b48f5bd
2 changed files with 23 additions and 0 deletions
20
kjg/python-the-hard-way/e40.py
Normal file
20
kjg/python-the-hard-way/e40.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Song(object):
|
||||
def __init__(self, lyrics):
|
||||
self.lyrics = lyrics
|
||||
|
||||
def sing_me_a_song(self):
|
||||
for line in self.lyrics:
|
||||
print(line)
|
||||
|
||||
|
||||
ly1 = ["Happy birthday to you", "I don't want to get sued", "So I'll stop right there"]
|
||||
ly2 = ["They rally around tha family","With pockets full of shells"]
|
||||
|
||||
happy_bday = Song(ly1)
|
||||
|
||||
bulls_on_parade = Song(ly2)
|
||||
|
||||
|
||||
happy_bday.sing_me_a_song()
|
||||
|
||||
bulls_on_parade.sing_me_a_song()
|
|
@ -142,3 +142,6 @@ analysis sample codes
|
|||
append list
|
||||
**** ex39
|
||||
How to use dictionary
|
||||
*** Python #8
|
||||
**** ex40
|
||||
How to use class
|
||||
|
|
Loading…
Reference in a new issue