原题:

打印出如下图案(菱形):

   *
***
*****
*******
*****
***
*

我的源码:

#!/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

最新文章

  1. 介绍几个好用的vs插件
  2. 【转】BAT 批处理脚本 教程
  3. Python中 "+=" 使用时的注意事项
  4. SQL Server 分页方法汇总
  5. 李洪强iOS经典面试题134-C语言
  6. unity, 取消ugui button响应键盘
  7. NPC AI驱动最基本过程
  8. Error:/etc/fstab:Read-only file system错误的解决办法
  9. 关于Sublime Text3 pyV8无法加载的问题
  10. Android手机开发者模式设置
  11. 【转】 Linux/Unix 进程间通信的各种方式及其比较
  12. Swift--基础(二)元组 断言 错误处理
  13. tshark命令行的使用(转)
  14. Andorid第三方库
  15. iOS极光推送SDK的使用流程
  16. SDL中按键对应的值
  17. RabbitMQ访问控制
  18. 微信小程序获取formId时提示"the formId is a mock one"
  19. 人人网框架导入uidGenerator的ID生成方式
  20. FZU软工实践–团队成员交换交接情况

热门文章

  1. Luogu P2567 [SCOI2010]幸运数字 容斥+脑子
  2. BZOJ 1116 [POI2008]CLO-Toll 并查集
  3. Win2008 R2 IIS FTP防火墙的配置
  4. css让文字,字母折行
  5. C++ 仿函数和适配器
  6. Difference Between static and default methods in interface
  7. buff/cache占用过高的问题
  8. Nginx-HTTP之ngx_http_top_header_filter
  9. map,实现技巧,id
  10. POJ 1837 -- Balance(DP)