【Python】【demo实验24】【练习实例】【打印图样】
2024-09-07 23:53:34
原题:
打印出如下图案(菱形):
*
***
*****
*******
*****
***
*
我的源码:
#!/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
最新文章
- 介绍几个好用的vs插件
- 【转】BAT 批处理脚本 教程
- Python中 ";+="; 使用时的注意事项
- SQL Server 分页方法汇总
- 李洪强iOS经典面试题134-C语言
- unity, 取消ugui button响应键盘
- NPC AI驱动最基本过程
- Error:/etc/fstab:Read-only file system错误的解决办法
- 关于Sublime Text3 pyV8无法加载的问题
- Android手机开发者模式设置
- 【转】 Linux/Unix 进程间通信的各种方式及其比较
- Swift--基础(二)元组 断言 错误处理
- tshark命令行的使用(转)
- Andorid第三方库
- iOS极光推送SDK的使用流程
- SDL中按键对应的值
- RabbitMQ访问控制
- 微信小程序获取formId时提示";the formId is a mock one";
- 人人网框架导入uidGenerator的ID生成方式
- FZU软工实践–团队成员交换交接情况
热门文章
- Luogu P2567 [SCOI2010]幸运数字 容斥+脑子
- BZOJ 1116 [POI2008]CLO-Toll 并查集
- Win2008 R2 IIS FTP防火墙的配置
- css让文字,字母折行
- C++ 仿函数和适配器
- Difference Between static and default methods in interface
- buff/cache占用过高的问题
- Nginx-HTTP之ngx_http_top_header_filter
- map,实现技巧,id
- POJ 1837 -- Balance(DP)