
1.for循环
print('输出一个九九乘法表:')
for i in range(1, 10):
for j in range(1, i+1):
print('{}*{}={}'.format(i, j, i * j), end='\t')
print()
2.while嵌套循环
# 99乘法表
i = 1
while i <= 9:
j = 1
while j <= i:
print(i, '*', j, '=', i * j, end=' ')
j += 1
print()
i += 1
九九乘法表实现

本文介绍了使用Python的for循环和while循环两种方式来实现九九乘法表的方法。通过具体的代码示例,展示了如何利用嵌套循环结构来生成常见的数学教育工具——九九乘法表。
46万+

被折叠的 条评论
为什么被折叠?



