python编写一个while循环语句求1+2+3…+100的和
#!/usr/bin/python3
sum100 = 0 #给变量一个初始值0
counter = 1 #给变量赋值1
while counter <= 100: #当条件counter小于等于100时,循环执行以下命令
sum100 += counter #sum100=sum100+counter
counter +=1 #counter=counter+1,即counter值递增直到100为止
print(sum100)