3. 条件语句使用规范

score = int(input("请输入一个分数:"))
if 100 >= score >= 90:
print("A")
elif score >= 80:
print("B")
elif score >= 60:
print("C")
elif score >= 0:
print("D")
else:
print("输入错误")


分数查询语句优化
score = int(input("请输入一个分数:"))
if 100 >= score >= 90:
print("A")
else:
if score >= 80:
print("B")
else:
if score >= 60:
print("C")
else:
if score >= 0:
print("D")
else:
print("输入错误")


for语句用法规范
print("计算1+2+3+...=")
result = 0
for i in range(101):
#range(start,end,step)只有一个数字两个数字三个数字依次增加
result += i
print(result)
for i in range(0,10,2):
print("I Love FishC")
for i in range(0,10,2):
print("i")
#此时i表示什么含义?


next 遍历编辑器
number = (i for i in range(3))
print(number.__next__())
print(number.__next__())
print(number.__next__())
number = tuple(number)
print("转化后的:",number)
 
 
posted @ 2020-09-22 15:24  celine227  阅读(224)  评论(0编辑  收藏  举报