for,while循环嵌套
1 a=0 2 while a<3: 3 j=0 4 while j<3: 5 print("*",end="")#行end取消默认换号 6 j+=1 7 print()#列 8 a+=1 9 a=0 10 while a<4: 11 b=0 12 while b <= a: 13 print("*",end="") 14 b+=1 15 print() 16 a+=1 17 18 19 # 1到100所有偶数的和 20 i=0 21 sum1=0 22 while i<=100: 23 if i%2==0: 24 sum1+=i 25 i+=1 26 print(sum1) 27 28 # for 变量 in 集合 29 # 语句 30 # i =0 31 # while i<5: 32 # print(i) 33 # i+=1; 34 35 list=[0,1,2,3,4] 36 for i in list: 37 print(i) 38 39 40 for i in "abfasf": 41 print(i) 42 #range()函数列表生成器 43 44 45 lis1 = range(5) 46 print(lis1) 47 print(lis1[0]) 48 49 for i in range(5): 50 print(i) 51 52 53 print("****************") 54 for i in range(3,5,10): 55 print(i) 56 57 for i in range(5,10): 58 print(i) 59 60 print("*-*-*-*-*-*-*-*-*-*-*-*") 61 for i in range(1,10): 62 for j in range(1,10): 63 print(i*j," ",end="") 64 print() 65 # for j in range(1,10): 66 # print(i+"*"+j+"="+i*j)