python program control flow

Process control:
1, sequence (from left to right, top to bottom)
2, select
3, cycle

Three, loop (python weak language, only the following two loops)
1, while
2, for

Cycle:
reciprocating execution

while loop
Syntax structure:

while 条件:
			# 循环体

break and continue keywords

break:终止循环
continue:跳过本次循环,进入下次循环

The use of multi-layer loops (pay attention to logic, pay attention to indentation)

for loop The for loop in
python is essentially used to iterate the elements in the container

for 变量 in 容器:
	# 每次会取出一个容器中的元素放在这个变量中
	print(变量)

range function

range(num)		# 表示0~num,[0, num)区间内的整数
	range(start, end)	# 表示[start, end)区间内的整数
	range(start ,end, step)	# 表示[start, end)区间内的整数,第三个参数表示步长

Guess you like

Origin blog.csdn.net/weixin_47514459/article/details/112722324