turtle 庫基礎練習
阿新 • • 發佈:2017-09-08
同心圓 () col fill tle 基礎練習 bsp for goto
1、畫一組同切圓
>>> turtle.circle(10)
>>> turtle.circle(20)
>>> turtle.circle(30)
>>> turtle.circle(40)
2、畫一組同心圓
r=0
while(r<120):
turtle.up()
turtle.goto(0,-40-r)
turtle.down()
turtle.circle(40+r)
r=r+40
3、畫一個五角星
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
4、畫一個黃色實心五角星
turtle.bgcolor("red")
>>> turtle.fillcolor("yellow")
>>> turtle.begin_fill()
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.left(144)
>>> turtle.forward(300)
>>> turtle.end_fill()
turtle 庫基礎練習