import turtle
tina = turtle.Turtle()
tina.shape('turtle')
your_name = input("What is your name")
tina.penup()
tina.forward(20)
tina.write("Why, hello there, " + your_name + "!")
tina.backward(20)
tina.color("green")
tina.left(90)
tina.forward(100)
tina.right(90)
tina.pendown()
tina.pencolor("red")
tina.forward(50)
tina.right(50)
tina.forward(50)
tina.right(100)
tina.forward(55)
tina.left(50)
tina.forward(55)
tina.penup()
tina.forward(30)
tina.pendown()
tina.dot(10)
tina.penup()
tina.goto(100, 100)
color = input("What color is the shape")
try:
if color == ("red"):
tina.write("Your are correct" + your_name + "!")
tina.backward(20)
elif color == ("green" or "Green"):
tina.write("Sorry, It is actually Red")
tina.backward(20)
elif color == ("black" or "Black"):
tina.write("Sorry, Its is actually Red")
tina.backward(20)
elif color == ("purple" or "Purple"):
tina.write("Sorry, It is actually Red")
tina.backward(20)
elif color == ("blue" or "Blue"):
tina.write("Sorry, It is actually Red")
tina.backward(20)
except:
tina.backward(20)
tina.write("Sorry, but that isn't a color")
tina.backward(20)
这是我的密码。我想知道如何让乌龟在整个程序中随机改变颜色。它应该在整个程序中每隔0.5秒改变一次颜色。我该怎么做。我试着随机输入。这是学校作业。请帮忙。在