感觉我这个还要简洁些,啊哈哈哈
print [x for x in range(100,1000) if str(x)[0:1]==str(x)[2:]]
print [x for x in range(100,1000) if str(x)[0:1]==str(x)[2:]]
2015-04-12
L = []
i=1
while i<=100 :
L.append(int(i*i))
i += 1
print sum(L)
i=1
while i<=100 :
L.append(int(i*i))
i += 1
print sum(L)
2015-04-11
sum = 0
x = 1
n = 1
while True:
sum += x
x=x*2
n = n+1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum += x
x=x*2
n = n+1
if n > 20:
break
print sum
2015-04-11
def average(*args):
t=sum(args)+ 0.0
return t and (t / len(args))
t=sum(args)+ 0.0
return t and (t / len(args))
2015-04-10
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
else:
if x%2==0:
continue
sum=sum+x
print sum
感觉这样比较好理解额
x = 0
while True:
x = x + 1
if x > 100:
break
else:
if x%2==0:
continue
sum=sum+x
print sum
感觉这样比较好理解额
2015-04-10
def move(n, a, b, c):
if n < 1:
return;
if n == 1:
print a,'-->',c
else:
move(n - 1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
if n < 1:
return;
if n == 1:
print a,'-->',c
else:
move(n - 1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
2015-04-10