我想让正方形出现在绿色线的开头,并且是蓝色的。我该怎么做?
from turtle import *
color('green')
begin_fill()
forward(200)
end_fill()
import turtle
turtle.color('blue')
# Creating a for loop that will run four times
for j in range(4):
turtle.forward(20) # Moving the turtle Forward by 150 units
turtle.left(90) # Turning the turtle by 90 degrees
到目前为止,正方形不是蓝色的,而是在绿色线的末端画的。
发布于 2022-11-20 21:06:51
将begin_fill/end_fill放在正方形的绘图周围,先画正方形,然后画直线:
import turtle as t
t.color('blue')
t.begin_fill()
for _ in range(4):
t.forward(20)
t.left(90)
t.end_fill()
t.color('green')
t.forward(200)
t.mainloop()
https://stackoverflow.com/questions/74511861
复制相似问题