python的九九乘法表
一.while循环打印九九乘法表
// while循环的九九乘法表
i = 1
while i <= 9:
j = 1
while j <= i:
print("{}*{}={}".format(j, i, i * j), end=" ")
j += 1
print()
i += 1
二.for循环打印九九乘法表
// for循环的九九乘法表
for i in range(1, 10):
for j in range(1, i + 1):
print("{}*{}={}".format(j, i, i * j), end=" ")
print()
三.使用循环打印三角形
1.for循环打印
// 第一种for循环:
for i in range(6):
print("*" * i)
// 第二种for循环:
for i in range(1, 6):
for j in range(1, i + 1):
print("*", end="")
print()
2.while循环
// 第一种while循环:
i = 1
while i < 6:
print("*" * i)
i += 1
// 第二种while循环:
i = 1
while i <= 5:
j = 1
while j <= i:
print("*", end="")
j += 1
print()
i += 1
( ̄▽ ̄)~*------ ٩(๑❛ᴗ❛๑)۶谢谢阅读!!!!!!!!!!!!!