python append,python的while分支

 2023-11-12 阅读 30 评论 0

摘要:python的while分支 1、輸出0到100,50不輸出,60到90是輸出平方 代碼 count=0while count<=49:print("loop",count)count+=1if count==50:pass count+=1while count>=51 and count<=59:print("loop",c

python的while分支

1、輸出0到100,50不輸出,60到90是輸出平方

代碼

count=0while count<=49:print("loop",count)count+=1if count==50:pass
count+=1while count>=51 and count<=59:print("loop",count)count+=1while count>=60 and count<=90:print("loop",count*count)count+=1while count>90 and count<=100:print("loop",count)count+=1

運行結果
在這里插入圖片描述
運行結果是對的,但是程序有些不簡潔

修改后的代碼為

count=0while count<=100:if count==50:passelif count>=60 and count<=90:print("loop",count*count)else:print("loop",count)count+=1        

運行結果
在這里插入圖片描述

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/172013.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息