sample1 球1+2+3…+100的和
sum=0
for i in range(1,101):
sum+=i
print sum
sample2:For循环应用与冒泡排序:
list=[10,12,14,19,20,22]
for i in range(1,len(list)):
for j in range(0,len(list)-1):
if list[j]>list[j+1]:
list[j],list[j+1]=list[j+1],list[j]
print list
list=["1","2","3","4"
,"5","6","7"]
for i in list:
print i
注:
原文:http://www.cnblogs.com/janicce-zhong/p/5106191.html