think python学习心得-(2)接口设计
【摘要】 TurtleWorld模块的下载与安装:
下载地址就是:http://thinkpython.com/swampy
安装方法把压缩包解压之后,用cmd cd到解压的安装目录下,运行:
python setup.py install
安装后就可以from swampy.TurtleWorld import *啦!
练习4.3
1-
from swampy....
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 bob
-
-
def square(t):
-
for i in range(4):
-
fd(t,100)
-
lt(t)
-
-
square(bob)
-
wait_for_user()
-
from swampy.TurtleWorld import *
-
-
world = TurtleWorld()
-
bob = Turtle()
-
print bob
-
-
def square(t,length):
-
for i in range(4):
-
fd(t,length)
-
lt(t)
-
-
square(bob,50)
-
wait_for_user()
-
from swampy.TurtleWorld import *
-
-
world = TurtleWorld()
-
bob = Turtle()
-
print bob
-
-
def square(t,length,n):
-
for i in range(n):
-
fd(t,length)
-
lt(t,360/n)
-
-
square(bob,50,6)
-
wait_for_user()
太简单了不写了
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()
文章来源: zclhit.blog.csdn.net,作者:zclhit_,版权归原作者所有,如需转载,请联系作者。
原文链接:zclhit.blog.csdn.net/article/details/50926069
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)