def he(x,y,z):
return x*100+y*10+z
print [ he(x,y,z) for x in range(1,10) for y in range(0,10) for z in range(0,10) if he(x,y,z) == he(z,y,x)]
return x*100+y*10+z
print [ he(x,y,z) for x in range(1,10) for y in range(0,10) for z in range(0,10) if he(x,y,z) == he(z,y,x)]
2015-09-11
def generate_tr(name, score):
if score >= 60:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
if score >= 60:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
2015-09-11
# -*- coding: utf-8 -*-
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
这空格的问题太麻烦了,不容易察觉,只要领会就行了
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
这空格的问题太麻烦了,不容易察觉,只要领会就行了
2015-09-11
for x in range( 1,10 ):
for y in range( 1,10 ):
if x < y:
print x*10+y
for y in range( 1,10 ):
if x < y:
print x*10+y
2015-09-11
print [m*100+n*10+r for m in range(1,10) for n in range(0,10) for r in range(0,10) if m==r]
2015-09-10
sum = 0
x = 1
n = 1
while True:
sum += x
x = x*2
n += 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum += x
x = x*2
n += 1
if n > 20:
break
print sum
2015-09-09
sum = 0
x = 1
while x < 100:
if x%2 != 0:
sum += x
x += 1
print sum
x = 1
while x < 100:
if x%2 != 0:
sum += x
x += 1
print sum
2015-09-09
L = ['Adam', 'Lisa', 'Bart']
L = [L[2],L[1],L[0]]
print L
L = [L[2],L[1],L[0]]
print L
2015-09-09