000677贴吧,喜羊羊与灰太狼小游戏,夺命双头鲨国语
import turtle
def draw_branch(length):
#绘制右侧树枝
if length >5:
if length == 10:
turtle.pencolor('green')
turtle.forward(length)
turtle.right(20)
draw_branch(length-15)
#绘制左侧树枝
turtle.left(40)
draw_branch(length-15)
#返回之前树枝
turtle.right(20)
turtle.backward(length)
if length == 10:
turtle.pencolor('yellow')
else:
turtle.pencolor('red')
def main():
turtle.pencolor('red')
turtle.pensize(5)
turtle.left(90)
turtle.penup()
turtle.backward(150)
turtle.pendown()
draw_branch(100)
turtle.exitonclick()
if __name__=='__main__':
main()
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
新手学习Python2和Python3中print不同的用法
Python基于os.environ从windows获取环境变量
网友评论