Answer:
Here is an example of how you can draw a ghost using the Python turtle module:
import turtle
def draw_ghost(x, y, color):
# Move the turtle to the specified position
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
# Set the turtle's color
turtle.color(color)
# Draw the ghost's head
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# Draw the ghost's eyes
turtle.penup()
turtle.goto(x - 20, y + 20)
turtle.pendown()
turtle.dot(10, "white")
turtle.penup()
turtle.goto(x + 20, y + 20)
turtle.pendown()
turtle.dot(10, "white")
# Draw the ghost's mouth
turtle.penup()
turtle.goto(x - 25, y - 25)
turtle.pendown()
turtle.width(10)
turtle.goto(x + 25, y - 25)
# Reset the turtle's state
turtle.penup()
turtle.home()
turtle.pendown()
turtle.width(1)
To use this function, you can call it with the desired x and y coordinates for the ghost's head, as well as the color you want the ghost to be. For example:
draw_ghost(100, 100, "purple")
draw_ghost(-100, -100, "orange")
turtle.done()
This will draw two ghosts, one at (100, 100) and one at (-100, -100), with the specified colors.
Step-by-step explanation: