sum = 0.0 先定义sun是带浮点的数,0.0+任何数就=xx.0。
for x in L 让x在L集里序列循环
新的sum = 0.0 + x循环出来的数
最后/4个,得出平均。
for x in L 让x在L集里序列循环
新的sum = 0.0 + x循环出来的数
最后/4个,得出平均。
2015-04-19
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2!=0:
sum+=x
continue
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2!=0:
sum+=x
continue
print sum
2015-04-19
>>> L[1:3]
['Adam', 'Lisa']
这个没问题?
不是
['Lisa','Bart']吗?
['Adam', 'Lisa']
这个没问题?
不是
['Lisa','Bart']吗?
2015-04-18
print [100*x+10*y+z for x in range(1,10) for y in range(1,10) for z in range(1,10) if x == z]
2015-04-18
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 style="color:red">'% (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td style="color:red">%s<td style="color:red">'% (name, score)
2015-04-18
def firstCharUpper(s):
return s[0:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-04-18
s = "Python was started in 1989 by \"Guido\".\nPython is free and easy to learn."
print s
print s
2015-04-18