![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
控制语句
王婷 Katrina
这个作者很懒,什么都没留下…
展开
-
Day 5 62 for循环结构,遍历各种可迭代对象_range对象
for 循环可迭代对象_range对象for循环通畅用于可迭代对象的遍历,for循环语法格式如下:for 变量 in 可迭代对象#序列循环体语句for x in (20,30,40): print(x*2)for y in 'abcdef': print(y,end='\t')d={'name':"xx",'age':18,"job":"程序员"}for x in d: print(x)for x in d.keys(): print(x)for x i原创 2021-03-22 17:42:47 · 249 阅读 · 1 评论 -
Day4 控制语句 60 循环结构
#测试while循环#测试while循环num=0while num<=10: print(num,end='\t') #'\t'是变成横向展现,否则是竖列的 num += 1 0 1 2 3 4 5 6 7 8 9 10#计算1-100之间数字的累加和num2=0sum_all=0while num2<=100: sum_all =sum_all +num2 num2+=1print('1-100所有数累加和:',sum_all原创 2021-03-22 16:54:12 · 74 阅读 · 0 评论 -
Day4 第四章,控制语句 任务59
#选择结构嵌套score = int(input('请输入一个分数:'))if score >100 or score <0: print ('请输入一个0-100的分数')else: if score>90: print("A") elif score>80: print('B') elif score>70: print('C') elif score>60:原创 2021-03-22 16:06:25 · 64 阅读 · 0 评论