The turtle is built in library so we don’t need to install separately. We just need to import the library into our Python environment. The Python turtle library consists of all important methods and functions that we will need to create our designs and images. Import the turtle library using the following command.
pip install turtle
pip3 install turtle
turtle is a pre-installed Python library that enables users to create pictures and shapes by providing them with a virtual canvas. The onscreen pen that you use for drawing is called the turtle and this is what gives the library its name.
import turtle t = turtle.Turtle() firstRowColor = ["blue", "black", "red"] for i in range(3): t.penup() t.pencolor(firstRowColor[i]) t.goto(i*110, 0) t.pendown() t.width(4) t.circle(40) secondRowColor = ["", "yellow", "", "green"] for i in range(1, 4, 2): t.penup() t.pencolor(secondRowColor[i]) t.goto(i* 55, -45) t.pendown() t.width(4) t.circle(40) t.end_fill() turtle.done()