1、if语法:
if condition :
result1
score =90
if score>=90 :
print('优秀')
if condition :
result1
else :
result2
if score>=90 :
print('优秀')
else :
print('及格')
if condition :
result1
elif condition :
result2
else :
result3
if score>=90 :
print('优秀')
elif score>=80 and score<90 :
print('良好')
elif score>60 and score<80 :
print('及格')
else :
print('不及格')
2、 for 循环
list1=['aaa','bbb','ccc','ddd']
for item in list1 :
print(item)
结果:
aaa
bbb
ccc
ddd
字典可以根据items() 循环 key value
dict1 = {'name':'wang','age':'30'}
for key,value in dict1.items():
print(key,value)
else :
print('循环结束')
3、while 循环
while condition :
result
while 循环可以使用continue break 结束循环