while loop
#while 布林值:
#若布林值为true,执行命令
#回到上方,做下一个的循环判断
n = 1
sum = 0
while n <=10:
print("n =",n)
sum = sum +n
n+=1
print(sum)
for loop
#for 变量 in 列表或者字符串:
#列表或者字符中的变量逐一取出,逐一处理
for x in [4,1,2]:
print(x)
for c in "hello":
print(c)
#range() 连续数字的列表
#range(3) = [0,1,2]
#range(5) = [0,1,2,3,4]
#range(3,6)= [3,4,5]
# for x in range(4):
#print(x)
sum = 0
for x in range(11):
sum = sum+x
print(sum)