think python学习心得-(2)接口设计
来源:互联网 发布:中国大国沙文主义 知乎 编辑:程序博客网 时间:2024/04/29 21:32
TurtleWorld模块的下载与安装:
下载地址就是:http://thinkpython.com/swampy
安装方法把压缩包解压之后,用cmd cd到解压的安装目录下,运行:
python setup.py install
安装后就可以from swampy.TurtleWorld import *啦!
练习4.3
1-
from swampy.TurtleWorld import *world = TurtleWorld()bob = Turtle()print bobdef square(t): for i in range(4): fd(t,100) lt(t) square(bob)wait_for_user()
2-
from swampy.TurtleWorld import *world = TurtleWorld()bob = Turtle()print bobdef square(t,length): for i in range(4): fd(t,length) lt(t) square(bob,50)wait_for_user()
3-
from swampy.TurtleWorld import *world = TurtleWorld()bob = Turtle()print bobdef square(t,length,n): for i in range(n): fd(t,length) lt(t,360/n) square(bob,50,6)wait_for_user()
4-
太简单了不写了
5-
直接用math包
画六边形:
from swampy.TurtleWorld import *world = TurtleWorld()bob = Turtle()def square(t,length,n): for i in range(n): fd(t,length) lt(t,360/n) for i in range(6): square(bob,50,3) lt(bob,60)wait_for_user()
0 0
- think python学习心得-(2)接口设计
- Think Python 学习笔记4:接口设计
- Think Python 第四章:接口设计
- think python学习心得-(1)关于函数和模块
- think python学习心得-(3)条件和递归
- think python学习心得-(4)有返回函数
- Think Python 第四章 接口设计 导入Swampy模块
- think python学习心得-(5)迭代与字符串的使用
- think python学习心得-(6)利用words.txt来进行填字游戏
- 《Think Python》笔记2
- Python学习心得实例(2)
- (think python 读书笔记)文件
- python学习心得(2) --- xml解析
- Python学习心得(1)
- python学习心得(1)
- (think python读书笔记)类和对象
- Python学习心得(一)类型
- Python学习心得实例(1)
- RHEL 7.0 yum源
- pixhawk上的 SPKT/DSM接口介绍
- 在VMware Workstation 12 PRO上安装CentOS 7 Minimal版
- poj-1548-Robots- 贪心+模拟 / 最小路径覆盖
- poj2438 哈密顿图
- think python学习心得-(2)接口设计
- java第九天
- HDOJ 1092 A+B for Input-Output Practice (IV)
- Earthstone: Easy Version
- WEB-laydate兼容bootstrap样式错误
- 解决数据库文件导入时出现的#1046 - No database selected错误。
- 42. Trapping Rain Water
- (problem)SyntaxError: Non-ASCII character '\xe7' in file,but no encoding declared;
- redis 主从复制及切换