TurtleWorld
来源:互联网 发布:我的淘宝怎么注册账号 编辑:程序博客网 时间:2024/05/29 12:03
1、画线
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 8 for i in range(4): 9 fd(bob,100) 10 lt(bob) 11 12 for i in range(4): 13 print('Hello') 14 15 wait_for_user()
输出:
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 8 def draw_square(Tt,length): 9 fd(Tt,length) 10 lt(Tt) 11 12 for i in range(4): 13 draw_square(bob,100)
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 # the functions lt and rt make 90-degree turns by default. 8 # lt(bob,45) turns bob 45 degrees to the left 9 def draw_eight_sides(Tt,length): 10 fd(Tt,length) 11 lt(Tt,45) 12 13 for i in range(8): 14 draw_eight_sides(bob,60)
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 # the functions lt and rt make 90-degree turns by default. 8 # lt(bob,45) turns bob 45 degrees to the left 9 def draw_polygon(Tt,length,n): 10 fd(Tt,length) 11 lt(Tt,360/n) 12 13 for i in range(6): 14 draw_polygon(bob,60,6)
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 # the functions lt and rt make 90-degree turns by default. 8 # lt(bob,45) turns bob 45 degrees to the left 9 def draw_polygon(Tt,length,n): 10 angle = 360/n 11 for i in range(n): 12 fd(Tt,length) 13 lt(Tt,angle) 14 15 draw_polygon(bob,60,6)
1 #!/usr/bin/python 2 from swampy.TurtleWorld import * 3 import math 4 world = TurtleWorld() 5 bob = Turtle() 6 print bob 7 # the functions lt and rt make 90-degree turns by default. 8 # lt(bob,45) turns bob 45 degrees to the left 9 def polygon(t,length,n): 10 angle = 360/n 11 for i in range(n): 12 fd(t,length) 13 lt(t,angle) 14 def draw_circle(Tt,r): 15 circumference = 2 * math.pi * r 16 n = 100 17 length = circumference/n 18 polygon(Tt,length,n) 19 20 draw_circle(bob,50)
输出:
0 0
- TurtleWorld
- TurtleWorld demo
- think python turtleworld练习
- 7.多态
- Byobu快捷键汇总
- (chrome)Adobe Flash 无法正常使用
- linux命令 - ln - 创建和删除软、硬链接
- 谷歌Google被墙打不开,找不到技术性资料怎么办?
- TurtleWorld
- ThreadLocal原理与源码分析
- android包体积减少利器,so动态加载
- paramiko遇到的问题
- Unity-Networking
- 处理freeMark值为空的情况
- 揭秘:成功产品经理的背后是什么?
- MAVEN Spring MVC Java Config
- hdu 2612 Find a way【BFS】