原题:
打印出如下图案(菱形):
*
***
*****
*******
*****
***
*
我的源码:
#!/usr/bin/python
# encoding=utf-8
# -*- coding: UTF-8 -*- # 打印以下图案:
# *
# ***
# *****
#*******
# *****
# ***
# * x = int(input("please input the number:\n")) # *最多的一行的*个数 for i in range(1,x+1):
print((x+1-i)*" ",end="")
print((2*i - 1)*"*")
for i in range(x-1,0,-1):
print((x+1-i)*" ",end="")
print((2*i - 1)*"*")
输出结果:
原题给出的方法:
————————(我是分割线)————————
参考:
1. RUNOOB.COM:https://www.runoob.com/python/python-exercise-example23.html
备注:
初次编辑时间:2019年10月3日15:38:37
环境:Windows 7 / Python 3.7.2