python中怎么做如图这样由字母组成的菱形
1个回答
2018-05-15 · 知道合伙人养生行家
关注
展开全部
#!/usr/bin/env python
# -*- coding:utf-8 -*-
print '\n'.join(['*'*7 for i in range(4)])
print '\n'
print '\n'.join(['*'*(i*2+1) for i in range(4)])
print '\n'
print '\n'.join([('*'*(i*2+1)).center(7, ' ') for i in range(4)])
print '\n'
print '\n'.join([('*'*(abs(i-3)*2+1)).center(7, ' ') for i in range(4)])
print '\n'
print '\n'.join([('*'*([i,abs(i-6)][i>3]*2+1)).center(7, ' ') for i in range(7)])
print '\n'
print '\n'.join(['*'*([i,abs(i-6)][i>3]*2+1) for i in range(7)])
各种型 没有达到你的要求 再追问
>>> ================================ RESTART ================================
>>>
*******
*******
*******
*******
*
***
*****
*******
*
***
*****
*******
*******
*****
***
*
*
***
*****
*******
*****
***
*
*
***
*****
*******
*****
***
*
# -*- coding:utf-8 -*-
print '\n'.join(['*'*7 for i in range(4)])
print '\n'
print '\n'.join(['*'*(i*2+1) for i in range(4)])
print '\n'
print '\n'.join([('*'*(i*2+1)).center(7, ' ') for i in range(4)])
print '\n'
print '\n'.join([('*'*(abs(i-3)*2+1)).center(7, ' ') for i in range(4)])
print '\n'
print '\n'.join([('*'*([i,abs(i-6)][i>3]*2+1)).center(7, ' ') for i in range(7)])
print '\n'
print '\n'.join(['*'*([i,abs(i-6)][i>3]*2+1) for i in range(7)])
各种型 没有达到你的要求 再追问
>>> ================================ RESTART ================================
>>>
*******
*******
*******
*******
*
***
*****
*******
*
***
*****
*******
*******
*****
***
*
*
***
*****
*******
*****
***
*
*
***
*****
*******
*****
***
*
追问
不要复制黏贴,看题目再回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询