python倒三角形乘法表
时间: 2023-10-17 08:37:32 浏览: 85
Sure! Here's an example of how you can create a downward-facing multiplication table triangle in Python:
```python
def print_multiplication_table(n):
for i in range(n, 0, -1):
for j in range(i, 0, -1):
print(f"{i * j:3}", end=" ")
print()
n = int(input("Enter the number of rows: "))
print_multiplication_table(n)
```
In this code, the `print_multiplication_table` function takes an input `n` which represents the number of rows in the triangle. It uses nested loops to iterate over each row and column, printing the product of the row and column values. The `end=" "` parameter in the print statement ensures that the numbers are separated by a space.
You can run this code and enter the desired number of rows to generate a downward-facing multiplication table triangle.
阅读全文