```
import turtle
import random

# Set up the screen
screen = turtle.Screen()
screen.title("Turtle Racing Game")
screen.bgcolor("white")

# Set up the turtles
red_turtle = turtle.Turtle()
red_turtle.color("red")
red_turtle.shape("turtle")
red_turtle.penup()
red_turtle.goto(-200, 100)

blue_turtle = turtle.Turtle()
blue_turtle.color("blue")
blue_turtle.shape("turtle")
blue_turtle.penup()
blue_turtle.goto(-200, 50)

green_turtle = turtle.Turtle()
green_turtle.color("green")
green_turtle.shape("turtle")
green_turtle.penup()
green_turtle.goto(-200, 0)

yellow_turtle = turtle.Turtle()
yellow_turtle.color("yellow")
yellow_turtle.shape("turtle")
yellow_turtle.penup()
yellow_turtle.goto(-200, -50)

# Set up the finish line
finish_line = turtle.Turtle()
finish_line.penup()
finish_line.goto(200, 150)
finish_line.pendown()
finish_line.goto(200, -200)

# Define the race function
def race():
    while True:
        red_turtle.forward(random.randint(1, 5))
        blue_turtle.forward(random.randint(1, 5))
        green_turtle.forward(random.randint(1, 5))
        yellow_turtle.forward(random.randint(1, 5))

        if red_turtle.position()[0] >= 200:
            turtle.write("Red turtle wins!", font=("Courier", 28, "bold"), align="right")
            break
        elif blue_turtle.position()[0] >= 200:
            turtle.write("Blue turtle wins!", font=("Courier", 28, "bold"), align="right")
            break
        elif green_turtle.position()[0] >= 200:
            turtle.write("Green turtle wins!", font=("Courier", 28, "bold"), align="right")
            break
        elif yellow_turtle.position()[0] >= 200:
            turtle.write("Yellow turtle wins!", font=("Courier", 28, "bold"), align="right")
            break

# Call the race function when the user presses the spacebar
turtle.onkey(race, "space")
turtle.listen()

# Keep the screen open until the user closes it
turtle.mainloop()
```
``` นำเข้าเต่านำเข้าแบบสุ่ม # ตั้งค่าหน้าจอ screen = Turtle.Screen() screen.title("Turtle Racing Game") screen.bgcolor("white") # ตั้งค่าเต่า red_turtle = Turtle.Turtle() red_turtle .color("red") red_turtle.shape("เต่า") red_turtle.penup() red_turtle.goto(-200, 100) blue_turtle = Turtle.Turtle() blue_turtle.color("blue") blue_turtle.shape("เต่า ") blue_turtle.penup() blue_turtle.goto(-200, 50) green_turtle = Turtle.Turtle() green_turtle.color("green") green_turtle.shape("เต่า") green_turtle.penup() green_turtle.goto(-200 , 0) yellow_turtle = Turtle.Turtle() yellow_turtle.color("yellow") yellow_turtle.shape("turtle") yellow_turtle.penup() yellow_turtle.goto(-200, -50) # ตั้งค่าเส้นชัย finish_line = เต่า .Turtle() finish_line.penup() finish_line.goto(200, 150) finish_line.pendown() finish_line.goto(200, -200) # กำหนดฟังก์ชัน race def race(): ในขณะที่ True: red_turtle.forward(random. randint(1, 5)) blue_turtle.forward(random.randint(1, 5)) green_turtle.forward(random.randint(1, 5)) yellow_turtle.forward(random.randint(1, 5)) ถ้า red_turtle.position ()[0] >= 200: Turtle.write("เต่าแดงชนะ!", font=("Courier", 28, "bold"), align="right") แบ่ง elif blue_turtle.position()[0] >= 200: Turtle.write("เต่าสีน้ำเงินชนะ!", font=("Courier", 28, "bold"), align="right") แบ่ง elif green_turtle.position()[0] >= 200: เต่า .write("เต่าเขียวชนะ!", font=("Courier", 28, "bold"), align="right") แบ่ง elif yellow_turtle.position()[0] >= 200: Turtle.write("Yellow เต่าชนะ!", font=("Courier", 28, "bold"), align="right") break # เรียกใช้ฟังก์ชันการแข่งขันเมื่อผู้ใช้กดสเปซบาร์ Turtle.onkey(race, "space") Turtle.listen () # เปิดหน้าจอไว้จนกว่าผู้ใช้จะปิดเต่า.mainloop() ```
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence