Selection construct
– if-else:– Indentation: tab/space 缩进很重要! 4 space or 1 tab is widely used in Python community – Nested if 嵌套
– elif
![]()
Iteration Construct:
– while loop– for loop—不需要定义条件,主要用于迭代遍历项目集如List,String…
– Termination of the loop: ▪ continue 当前循环内的代码不执行了,回到循环继续循环
▪ break 直接退出循环,不管这个循环还要循环几次,都不循环了
![]()
Function
![]()
Main Function
![]()