编程输出9X9乘法口诀。结果显示如下: 1x1=1 1x2=2 2x2=4 1x3=3 2x3=6 3x3=9 1x4=4 2x4=8 3x4=12 4x4=16 1x5=5 2x5=10 3x5=15 4x5=20 5x5=25 1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36 1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49 1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64 1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81
时间: 2023-08-06 21:26:49 浏览: 89
当然可以,以下是Python代码实现:
```python
for i in range(1, 10):
for j in range(1, i+1):
print("{}x{}={}\t".format(j, i, i*j), end="")
print()
```
输出结果如下:
```
1x1=1
1x2=2 2x2=4
1x3=3 2x3=6 3x3=9
1x4=4 2x4=8 3x4=12 4x4=16
1x5=5 2x5=10 3x5=15 4x5=20 5x5=25
1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36
1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49
1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64
1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81
```
相关问题
请用python写出乘法表,乘积结果长度设置为2,结果之间空4格,倒序乘法表,右对齐,输入n,则输出从1至n的乘法口诀
好的,以下是Python代码实现:
```python
n = int(input("请输入n: "))
if n<1:
print("输入的数字必须大于等于1!")
else:
for i in range(n, 0, -1):
for j in range(i, 0, -1):
product = i * j
if product <= 9:
print(str(j) + "x" + str(i) + "= " + str(product), end=" ")
else:
print(str(j) + "x" + str(i) + "=" + str(product), end=" ")
print()
```
输出结果如下:
```
请输入n: 9
9x9=81 8x9=72 7x9=63 6x9=54 5x9=45 4x9=36 3x9=27 2x9=18 1x9= 9
8x8=64 7x8=56 6x8=48 5x8=40 4x8=32 3x8=24 2x8=16 1x8= 8
7x7=49 6x7=42 5x7=35 4x7=28 3x7=21 2x7=14 1x7= 7
6x6=36 5x6=30 4x6=24 3x6=18 2x6=12 1x6= 6
5x5=25 4x5=20 3x5=15 2x5=10 1x5= 5
4x4=16 3x4=12 2x4= 8 1x4= 4
3x3= 9 2x3= 6 1x3= 3
2x2= 4 1x2= 2
1x1= 1
```
输出 9*9 乘法口诀表。 程序分析:分行与列考虑,共9行9列,i控制行,j控制列。
好的,以下是Python代码实现:
```
for i in range(1, 10):
for j in range(1, i+1):
print('{}x{}={}\t'.format(j, i, i*j), end='')
print()
```
输出结果为:
```
1x1=1
1x2=2 2x2=4
1x3=3 2x3=6 3x3=9
1x4=4 2x4=8 3x4=12 4x4=16
1x5=5 2x5=10 3x5=15 4x5=20 5x5=25
1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36
1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49
1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64
1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)