TURTLE ATTRIBUTES AND METHODS IN PYTHON

GOCOURSE


Turtle Attributes And Methods

Python's turtle graphics give you a lot of options for controlling the turtle cursor and drawing various shapes and patterns on the screen.

Turtle Attributes:

  • position() -provides a tuple of coordinates as the current position of the turtle.
  • heading() -returns the current heading angle of the turtle in degrees.
  • color() -returns a tuple of RGB values representing the turtle's current color.
  • pensize() -returns the current pen size of the turtle.
  • speed() -returns the current speed of the turtle.

Turtle Methods:

  1. forward(distance): This option propels the turtle forward by a predetermined amount.
  2. backward(distance): This option sends the turtle back the specified amount of time.
  3. right(angle): This option moves the turtle to the right at the specified degree angle.
  4. left(angle): Moves the turtle to the left at the specified degree angle.
  5. penup() : raises the turtle's pen so that it can't draw while it moves.
  6. pendown():puts the pen down on the turtle so it can draw while it moves.
  7. setposition(x, y):sets the position of the turtle to the specified x and y coordinates.
  8. setheading(angle) :sets the heading angle of the turtle to the specified degree.
  9. dot(size, color) :draws a dot of the specified size and color at the turtle's current position.
  10. circle(radius, extent):draws a circle with the radius and extent you specify (the percentage of the circle to be drawn).
  11. begin_fill():begins to fill the space that the turtle's movements have enclosed.
  12. end_fill():stops occupying the space that the turtle's movements have enclosed.






More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send