import turtle
def Draw_turtle(my_turtle):
for i in range(1,5):
my_turtle.turtle.forward(100)
my_turtle.turtle.right(90)
window = turtle.Screen()
window.bgcolor('green')
Alex = turtle.Turtle()
Alex.color('black')
Alex.speed(2)
Alex.shape('triangle')
Draw_turtle(Alex)
我还不知道编码,当我运行上面的代码时什么也没发生。谁能帮我。
答案 0 :(得分:0)
您拥有大部分正确的作品,而且顺序大致正确。我们只需要在缩进,用法和样式方面对您的代码进行一些微调:
import turtle
def draw_square(my_turtle):
for i in range(4):
my_turtle.forward(100)
my_turtle.right(90)
window = turtle.Screen()
window.bgcolor('green')
alex = turtle.Turtle()
alex.color('black')
alex.speed('slow')
alex.shape('triangle')
draw_square(alex)
window.mainloop()