码迷,mamicode.com
首页 > 其他好文 > 详细

Exercise 40 - class

时间:2019-10-01 13:56:28      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:nbsp   ISE   ext   around   output   HERE   day   you   class   

 

class Song(object):
    def __init__(self, lyrics):
        self.lyrics = lyrics

    def sing_me_a_song(self):
        for line in self.lyrics:
            print(line)


happy_bday = Song(["Happy birthday to you",
                   "I don‘t want to get sued",
                   "So I‘ll stop right there"])

bulls_on_parade = Song(["They rally around the family",
                        "With pockets full of shells"])

happy_bday.sing_me_a_song()

bulls_on_parade.sing_me_a_song()

output

Happy birthday to you
I dont want to get sued
So Ill stop right there
They rally around the family
With pockets full of shells

 

2019-10-01

17:04:15

Exercise 40 - class

标签:nbsp   ISE   ext   around   output   HERE   day   you   class   

原文地址:https://www.cnblogs.com/petitherisson/p/11615102.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!