Continue与break的区别
continue 是跳出本次循环,回到循环体的开头;break语句则是跳出循环体,直接执行循环体后面的语句。

"打印出1到一百的奇数"
i=0
while i<=100:
i+=1
if i%2==0:
continue
print(i)
"打印1到一百的偶数"
i=0
while i<=100:
i+=1
if i%2!=0:
continue
print(i)
 WHILE Else语句 检测循环退出情况 
day=1
while day<=7:
answer=input("这里是七天打卡器,加油奥,今天你打卡了吗?\n")
if answer!="有":
print("七天连续打卡失败,希望您坚持不懈奥。")
break
day+=1
else:
print("恭喜你完成七天打卡。")
 循环结构的嵌套 九九乘法表:
i=1
while i<=9:
j=1
while j<=i:
print (j,"*",i,"=",i*j,end=" ")//end=" "防止自动换行 因为Python默认自动换行
print(" ")//换行作用
i+=1

 for循环
   数字不是可迭代对象,例如计算1到1000000的和的时候就不可以像下面这样:  这时候我们需要借助For的好伙伴-------range(),下面是range()的三种形式:  Tips:无论你使用哪一种,他的参数都只能是整型int。
第一种:range(stop)自带了一个stop参数,将生成一个从0开始到stop的整数序列(不包含stop)。 第二种:range(start,stop),顾名思义可以决定开始与结束的数字,但数列中包括start,不包括stop。 第三种:与第二种类似,但加上个step,即步长。跳跃选取数字作为数列。
"for循环中range的三种用法:"
for i in range (10):
print(i,end=" ")
print(" ")
for j in range(5,10):
print(j,end=" ")
print(" ")
for k in range(5,10,2):
print(k,end=" ")
print(" ")
for m in range(10,5,-2):
print(m,end=" ")
 下面我们来实现一个案例,使用for循环计算1到1000000的和:
sum=0
for i in range (1000001):
sum=sum+i
print(sum)
 利用for循环的嵌套,计算一到10的素数(除了1和其本身,不能被其他数整除的数。)
for i range(2,11):
for j in range(2,i):
if i%j==0:
break
else:
print(i)

|