7.while循环,exit,contiune,break

左心房为你撑大大i 提交于 2019-11-30 02:52:11
while循环count=0while count<100:    print("我要一个小宝宝")    count+=1求偶数count=0while count<100:    if count%2==0:        print("我要一个小宝宝", count)    count+=1求奇数count=0while count<100:    if count%2==1:        print("我要一个小宝宝", count)    count+=1import  randomn=random.randint(1,10)print(n)count=0while count<5:    user_guess=int(input("请输入:"))    if user_guess>n:        print("太大了")    elif user_guess<n:        print("太小了")    else:        print("niubility")        exit() # 终止整个程序,print(count)不打印    count+=1print(count)import  randomn=random.randint(1,10)print(n)count=0while count<5:    user_guess=int(input("请输入:"))    if user_guess>n:        print("太大了")    elif user_guess<n:        print("太小了")    else:        print("niubility")        break # 终止整个循环,print(count)打印    count+=1print(count)count=0while count<100:    count+=1    if count>10 and count<20:        continue # 终止当次循环,继续下次循环    print(count)else:# 当循环正常结束,条件不成立了,执行    print("Dsds")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!