-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex40.py
44 lines (31 loc) · 941 Bytes
/
ex40.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#coding:utf-8
class Song(object):
def __init__(self, lyrics): #创建歌曲类别
self.lyrics = lyrics
def sing_me_a_song(self): # 创建循环结构
for line in self.lyrics:
print line
hally_bday = Song(["Happy birthday to you",
"I don't want to get sued",
"So I'll stop right there"])
bulls_on_parde = Song(["They rally around tha familly",
"With pockets full of shells"])
# 类别的输出,用a.AA()形式
hally_bday.sing_me_a_song()
bulls_on_parde.sing_me_a_song()
# 附件题
class Person(object):
def __init__(self, name):
self.name = name
def getName(self):
return self.name
def breast(self, n):
self.breast = n
def color(self, color):
print "%s is %s" % (self.name, color)
def how(self):
print "%s breast is %s" %(self.name, self.breast)
girl = Person('canglaoshi')
girl.breast(90)
girl.color("white")
girl.how()