def generate_tr(name, score):
if score < 60:
return '<tr><td >%s</td><td style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td >%s</td><td>%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 style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td >%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name, score) for name, score in d.iteritems()]
2015-07-10
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
move(n-1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
return
move(n-1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
2015-07-10
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = 2 ** n
n = n + 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
x = 2 ** n
n = n + 1
if n > 20:
break
print sum
2015-07-10
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
n = n + 1
x = x + 1
print sum
这才是1+++20的值 吧!!!!
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
n = n + 1
x = x + 1
print sum
这才是1+++20的值 吧!!!!
2015-07-10
def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
move(4, 'A', 'B', 'C')
2015-07-09
months = set(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec',])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
2015-07-09
score = 77
if score>=80:
print 'excellent'
elif score>=70:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
if score>=80:
print 'excellent'
elif score>=70:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
2015-07-09
for x in ['1','2','3','4','5','6','7','8','9']:
for y in ['1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
for y in ['1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
2015-07-09