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()]
2016-05-16
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2016-05-16
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
2016-05-16
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
2016-05-16
已采纳回答 / Eason_Wang
#先执行for 循环,比如这里是先:for x in range(100, 1000) #接下来是循环内部的判断,我们通过添加 if 判断语句,打算只添加符合要求的选项 if x/100 == x%10: # x/100 表示取最高位有效数字, x%10 表示取各位,或最低位有效数字 #在if 满足的情况下,把这个数加进列表 list, #这里等价于print [x for x in range(100,1000) if x/100 ==x%10] 中的第一...
2016-05-15
s = set(str.lower(item) for item in ['Adam', 'Lisa', 'Bart', 'Paul'])
print 'adam' in s
print 'bart' in s
print 'adam' in s
print 'bart' in s
2016-05-15
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2:
sum = sum + x
else:
continue
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2:
sum = sum + x
else:
continue
print sum
2016-05-15
#-*-coding:utf-8-*-
L = [95.5,85,59]
print ("第一名是:"str(L[0]))
print ("第二名是:"str(L[1]))
print ("第三名是:"str(L[1]))
print ('this is list 集合。')
L = [95.5,85,59]
print ("第一名是:"str(L[0]))
print ("第二名是:"str(L[1]))
print ("第三名是:"str(L[1]))
print ('this is list 集合。')
2016-05-15
L = []
for x in range(1,10):
for y in range(10):
for z in range(10):
if x == z:
L.append(x*100+y*10+z)
print L
for x in range(1,10):
for y in range(10):
for z in range(10):
if x == z:
L.append(x*100+y*10+z)
print L
2016-05-15
注意*号
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
2016-05-15
def greet(content = 'world'):
print 'hello,',content,'.'
greet()
greet('Bart')
print 'hello,',content,'.'
greet()
greet('Bart')
2016-05-15
x1 = 1
d = 3
n = 100
x100 =x1+(n-1)*d
s = (x100+x1)*n/2
print s
d = 3
n = 100
x100 =x1+(n-1)*d
s = (x100+x1)*n/2
print s
2016-05-14