当前位置:   article > 正文

python海龟作图画爱心_python1|海龟作图法

for x in range(100)t.

输入代码:

import turtle

t = turtle.Pen()

for x in range(100):

t.circle(x)

t.left(30)

画出来是这样的:

把circle改成forward:

import turtle

t = turtle.Pen()

for x in range(100):

t.forward(x)

t.left(30)

就变成这样了:

换成红的:

import turtle

t = turtle.Pen()

t.pencolor("red")

for x in range(100):

t.forward(x)

t.left(30)

颜色太单调了,加几个颜色:

import turtle

t = turtle.Pen()

colors = ["red","blue","green","purple"]

for x in range(100):

t.pencolor(colors[x%4])

t.forward(x)

t.left(30)

背景不能老是白的:

import turtle

turtle.bgcolor("black")

t = turtle.Pen()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/192177
推荐阅读
相关标签
  

闽ICP备14008679号