用Python输出一个菱形
时间: 2023-04-10 14:05:20 浏览: 101
以下是用 Python 输出菱形的代码:
```
n = int(input("请输入菱形的行数:"))
for i in range(1, n+1):
print(" "*(n-i) + "* "*i)
for i in range(n-1, 0, -1):
print(" "*(n-i) + "* "*i)
```
输入行数为 5 时,输出结果为:
```
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
```
相关问题
用python输出一个菱形
我可以帮你用Python输出一个菱形: print(" * ")
print(" * * ")
print(" * * ")
print("* *")
print(" * * ")
print(" * * ")
print(" * ")
python输出一个菱形
答案:下面是用Python输出一个菱形的代码:print(" * ")
print(" *** ")
print(" ***** ")
print("*******")
print(" ***** ")
print(" *** ")
print(" * ")
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_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)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)