sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2 == 0 :
continue
else :
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2 == 0 :
continue
else :
sum = sum + x
print sum
2015-02-28
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0]+':',x[1]
for x in s:
print x[0]+':',x[1]
2015-02-27
最赞回答 / sump
python中用缩进区分不同的代码快, 第一个return在for循环完成后跳出, 第二个return属于for循环中的语句, 所以在for循环执行中就跳出了
2015-02-27
print [2, 12, 30, 56, 90, 132, 182, 240, 306, 380, 462, 552, 650, 756, 870, 992, 1122, 1260, 1406, 1560, 1722, 1892, 2070, 2256, 2450, 2652, 2862, 3080, 3306, 3540, 3782, 4032, 4290, 4556, 4830, 5112, 5402, 5700, 6006, 6320, 6642, 6972, 7310, 7656, 8010, 8372, 8742, 9120, 9506, 9900]