Python输出字母图案
时间: 2023-06-20 12:08:11 浏览: 132
以下是一个输出字母图案的 Python 代码示例:
```python
# 定义字母图案函数
def print_pattern(char, rows):
for i in range(1, rows+1):
print(" "*(rows-i) + char*i)
# 输出字母A图案
print_pattern("A", 5)
# 输出字母B图案
print_pattern("B", 5)
```
输出结果:
```
A
AA
AAA
AAAA
AAAAA
B
BB
BBB
BBBB
BBBBB
```
你可以根据需要修改字母和行数来输出不同的图案。
相关问题
python 用*输出字母C的图案
可以使用如下代码输出字母C的图案:
```
print(" *****")
print(" **")
print("**")
print("**")
print(" **")
print(" *****")
```
运行以上代码,输出结果如下:
```
*****
**
**
**
**
*****
```
python 用*号输出字母C的图案
以下是 Python 代码:
```
print(' * * *')
print(' * *')
print('* *')
print('*')
print('*')
print('*')
print('* *')
print(' * *')
print(' * * *')
```
输出结果:
```
* * *
* *
* *
*
*
*
* *
* *
* * *
```