Turtle function in python

“Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all over it! 

some of the functions are listed below 

1.Turtle() - Creates and returns a new tutrle object

2. forward() -  Moves the turtle forward by the specified amount

3. backward() -  Moves the turtle backward by the specified amount

4. left() - Turns the turtle counter clockwise

5. right() - Turns the turtle clockwise

6. penup() - Picks up the turtle’s Pen

7. pendown() - Puts down the turtle's Pen

8. color() - Changes the color of the turtle’s pen

9. fillcolor() - Changes the color of the turtle will use to fill a polygon

10. heading() - Returns the current heading

11. position() - Returns the current position

12. goto() - Move the turtle to position x,y

13. begin_fill() - Remember the starting point for a filled polygon

14. end_fill() - Close the polygon and fill with the current fill color

15. shape() - Should be ‘arrow’, ‘classic’, ‘turtle’ or ‘circle’

This is the simple program to implement the turtle function to draw some circles

import turtle

myTurtle = turtle.Turtle(shape="turtle")

myTurtle.circle(50)

myTurtle.penup()

myTurtle.setposition(60, 0)

myTurtle.pendown()

myTurtle.circle(50)

myTurtle.penup()

myTurtle.setposition(-60, 0)

myTurtle.pendown()

myTurtle.circle(50)

myTurtle.penup()

myTurtle.setposition(30, 0)

myTurtle.pendown()

myTurtle.circle(50)

myTurtle.penup()

myTurtle.setposition(-30, 0)

myTurtle.pendown()

myTurtle.circle(50)

turtle.getscreen()._root.mainloop()

Posted on by