#小练习 类与继承 分类: python 小练习 2013-04-26 15:27 175人阅读 评论(0) 收藏
#coding:utf-8
class Hum:
def __init__(self,name,age):
self.name = name
self.age = age
class Stu(Hum): # inherit class Hum
def __init__(self,name,age,score):
Hum.__init__(self,name,age)
self.score = score
def tell(self):
print 'Name:',self.name
print 'Age:' ,self.age
print 'Score:',self.score
s=Stu('Sam',30,90)
s.tell()
class Hum:
def __init__(self,name,age):
self.name = name
self.age = age
class Stu(Hum): # inherit class Hum
def __init__(self,name,age,score):
Hum.__init__(self,name,age)
self.score = score
def tell(self):
print 'Name:',self.name
print 'Age:' ,self.age
print 'Score:',self.score
s=Stu('Sam',30,90)
s.tell()
版权声明:本文为博主原创文章,未经博主允许不得转载。