import math
def is_sqr(x):
n=math.sqrt(x)
return n%(1.0)==0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
n=math.sqrt(x)
return n%(1.0)==0
print filter(is_sqr, range(1, 101))
2016-01-27
class Person(object):
__count = 0
def __init__(self, name):
Person.__count = Person.__count + 1
self.name = name
print Person.__count
p1 = Person('Bob')
p2 = Person('Alice')
print 'attributeerror'
这不是第一次了吧。。。
__count = 0
def __init__(self, name):
Person.__count = Person.__count + 1
self.name = name
print Person.__count
p1 = Person('Bob')
p2 = Person('Alice')
print 'attributeerror'
这不是第一次了吧。。。
2016-01-26
def count():
fs = []
for i in range(1, 4):
fs.append(i**2)
return fs
f = count()
print f[0],f[1],f[2]
fs = []
for i in range(1, 4):
fs.append(i**2)
return fs
f = count()
print f[0],f[1],f[2]
2016-01-26
import math
def is_sqr(x):
return math.sqrt(x) in range(1,100)
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x) in range(1,100)
print filter(is_sqr, range(1, 101))
2016-01-25
import math
def kaifang(a):
return pow(a,0.5)
def add(x, y, f):
return f(x) + f(y)
print add(25, 9, kaifang)
def kaifang(a):
return pow(a,0.5)
def add(x, y, f):
return f(x) + f(y)
print add(25, 9, kaifang)
2016-01-24