来添加元素至尾部,使用pop()从尾部删除元素,实际上形成了一个LIFO(后进先出)队列的数据结构,也称栈;如果用pop(0)来删除元素,则创建了一个FIFO(先进先出)队列。
循环打印1-100,第50次不打印,第60-80次,打印对应值的平方count=0whilecount<100:count+=1ifcount==50:#当count为50时,跳出此次循环continueelif60<=count<=80:print(count**2)else:print(count)·优化猜年龄游戏,允许用户最多猜3次,中间猜对了,直接跳出循环,猜了3次后,再
age=input('age:')hometown=input('hometown:')profession=input('profession:')#通过占位符格式化输出info='''-----------infoof%s-------------name:%sage:
![](http://i2.51cto.com/images/blog/201807/15/3ca3d4d31e2e079688ee85769b6ad2c0.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3po
![](http://i2.51cto.com/images/blog/201807/15/7ddf1a0ce03b6bcf8b348baf2a2eee2f.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3po
![](http://i2.51cto.com/images/blog/201807/15/4853793bee4fb03f870cd51156fb270b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3po
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号