1. 程式人生 > >turtle庫基礎練習

turtle庫基礎練習

port right down tle yellow war rtl llc fill

同切圓

>>> import turtle
>>> turtle.circle(10)
>>> turtle.circle(30)
>>> turtle.circle(50)
>>> turtle.circle(80)

同心圓

>>>turtle.circle(30)
>>> turtle.up()
>>> turtle.goto(0,-20)
>>> turtle.down()
>>> turtle.circle(50)
>>> turtle.up()
>>> turtle.goto(0,-40)
>>> turtle.down()
>>> turtle.circle(70)

五角星

>>>turtle.forward(50)
>>> turtle.right(144)
>>> turtle.forward(50)
>>> turtle.right(144)
>>> turtle.forward(50)
>>> turtle.right(144)
>>> turtle.forward(50)
>>> turtle.right(144)
>>> turtle.forward(50)

紅背景黃五星

>>> turtle.bgcolor(‘red‘)

>>> turtle.color(‘yellow‘)
>>> turtle.fillcolor(‘yellow‘)
>>> turtle.begin_fill()
>>> turtle.forward(100)
>>> turtle.right(144)
>>> turtle.forward(100)
>>> turtle.right(144)
>>> turtle.forward(100)
>>> turtle.right(144)
>>> turtle.forward(100)
>>> turtle.right(144)
>>> turtle.forward(100)
>>> turtle.end_fill()

turtle庫基礎練習