# -*- coding:utf-8-*-
def get_grade(self):
if self.__score>=80:
return "A-优秀"
elif self.__score>=60:
return "B-及格"
return "C-不及格"
print p1.get_grade()
print p2.get_grade()
print p3.get_grade()
没通过的是不是忘了加# -*- coding: utf-8 -*-了
def get_grade(self):
if self.__score>=80:
return "A-优秀"
elif self.__score>=60:
return "B-及格"
return "C-不及格"
print p1.get_grade()
print p2.get_grade()
print p3.get_grade()
没通过的是不是忘了加# -*- coding: utf-8 -*-了
2016-10-02
def performance(k):
print ('call ' + f.__name__ + '()...', time.asctime())
return k
@performance
def f(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print (f(10))
print ('call ' + f.__name__ + '()...', time.asctime())
return k
@performance
def f(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print (f(10))
2016-10-01
import math
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 101))
2016-10-01
import os
print os.path.isdir(r'/data/webroot/resource')
print os.path.isfile(r'/data/webroot/resource')
这样就可以了。
print os.path.isdir(r'/data/webroot/resource')
print os.path.isfile(r'/data/webroot/resource')
这样就可以了。
2016-09-30
import math
def is_sqr(x):
return round(math.sqrt(x),0)*int(math.sqrt(x))==x
print filter(is_sqr,range(1, 101))
def is_sqr(x):
return round(math.sqrt(x),0)*int(math.sqrt(x))==x
print filter(is_sqr,range(1, 101))
2016-09-30
import math
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 101))
2016-09-30