
题目如图:通过turtle库绘制一个图形,外面是黄色正方形,内部是红色圆形。
import turtle
LENGTH = 200
t = turtle.Turtle('turtle')
t.up()
t.goto(-LENGTH / 2, LENGTH / 2)
t.pd()
t.fillcolor('yellow')
t.begin_fill()
for i in range(4):
t.fd(LENGTH)
t.right(90)
t.end_fill()
t.goto(0, LENGTH / 2)
t.fillcolor('red')
t.begin_fill()
t.circle(-LENGTH / 2)
t.end_fill()
turtle.done()

import turtle as t
t.color('black','yellow')
t.begin_fill()
for i in range(4):
t.forward(200)
t.left(90)
t.end_fill()
t.color('black','red')
t.begin_fill()
t.forward(100)
t.circle(100)
t.end_fill()
t.mainloop()