def __init__(self, name, score):
self.name=name
self.__score=score
def get_grade(self):
if self.__score>=80:
return 'A'
if self.__score>=60 and self.__score<80:
return 'B'
return 'C'
self.name=name
self.__score=score
def get_grade(self):
if self.__score>=80:
return 'A'
if self.__score>=60 and self.__score<80:
return 'B'
return 'C'
2016-05-29
print 1
print 2
print 'attributeerror'
标准答案
print 2
print 'attributeerror'
标准答案
2016-05-29
def calc_prod(lst):
def cj():
def f(x,y):
return x*y
return reduce(f,lst)
return cj
f = calc_prod([1, 2, 3, 4])
print f()
def cj():
def f(x,y):
return x*y
return reduce(f,lst)
return cj
f = calc_prod([1, 2, 3, 4])
print f()
2016-05-29
def __init__(self, name, gender, course):
super(Teacher,self).__init__(name,gender)
self.course=course
super(Teacher,self).__init__(name,gender)
self.course=course
2016-05-28
def get_grade(self):
if self.__score >= 80:
return 'A'
elif self.__score >= 60:
return 'B'
else:
return 'C'
if self.__score >= 80:
return 'A'
elif self.__score >= 60:
return 'B'
else:
return 'C'
2016-05-28
“以单下划线开头的属性"_xxx"虽然也可以被外部访问,但是,按照习惯,他们不应该被外部访问。”这句话纯扯淡。又要说,又不说清。还不如不说!
2016-05-27
L1 = [p1, p2, p3]
L2 = sorted(L1,lambda p1,p2:cmp(p1.name,p2.name))
for n in L2:
print n.name
L2 = sorted(L1,lambda p1,p2:cmp(p1.name,p2.name))
for n in L2:
print n.name
2016-05-27