1.分支结构:if
if:
score = float(input("请输入一个数字:"))
if(score<60):
print("不及格")
elif (score<80):
print("良")
elif (score <=100):
print("优秀")
else:
print("输入有误")
2.循环: for、while
for :
for_stmt ::= "for" target_list "in" expression_list ":" suite
["else" ":" suite]
while
while_stmt ::= "while" assignment_expression ":" suite
["else" ":" suite]
flag = float(input("请输入一个数字:"))
while(flag == 1):
score = float(input("请输入一个数字:"))
if (score < 60):
print("不及格")
elif (score < 80):
print("良")
elif (score <= 100):
print("优秀")
else:
print("输入有误")
else:
print("退出while")
break continue
L1= [1,2,3,4,5]
for el in L1:
if(el == 3):
# break
continue
print(el)
else:
print(el)
附:
java 集合有哪些:
Collection:
List: 存储元素,有序、可重复
Set: 存储元素,不可重复、无序
Map:
kv:存储一对一对的数据