# 一、学习内容

## for循环

# for循环语句

for i in range(5):
print(i, end="\t")  # 0 1 2 3 4

print("\n", "-" * 50)

for i in range(0, 10, 3):  # (开始数字，结束数字，间隔数字)
print(i, end="\t")  # 0,3,6,9

print("\n", "-" * 50)

for i in range(-10, -100, -30):
print(i, end="\t")  # -10 -40 -70

print("\n", "-" * 50)

name = "BeiJing"
for x in name:  # 每个字符分别取出来
print(x, end="\t")  # B	e	i	J	i	n	g

print("\n", "-" * 50)

a = ["aa", "bb", "cc", "dd"]
for i in range(len(a)):
print(i, a[i], end="\t")  # 0 aa	1 bb	2 cc	3 dd

print("\n", "-" * 50)



## while循环

# while循环
i = 0
while i < 5:
print("是第%d次执行循环" % (i + 1))
i += 1
print()  # 将结果分开

# 1~100求和
i = 0
k = 0
while i <= 100:
k += i
i += 1
print("1~100的和%d" % k)

print("\n", "-" * 50)



## while__else循环

# while_else语句
n = 0
while n < 5:
print(n, "小于5")
n += 1
else:  # 当判断为false时运行
print(n, "大于等于5")

print("\n", "-" * 50)



## break，continue语句

beak 可以直接跳出循环

### break

for i in range(5):
print(i, end="\t"）
if i==3:break


### continue

continue 可以跳过下面语句直接进行下一次循环

for i in range(5):
if i == 3: continue
print(i, end="\t")


# 二、作业

【03】用Python写九九乘法表【对齐版】

04-10 4万+

10-22 1745
07-07 39
08-09 1万+
08-08 2万+
06-03 2万+
08-04 2922
07-19 2万+
05-01 4481
06-17 1万+
10-13 1154
03-08 9083