Lesson-13: Python Turtle Module (Turtle Library)

Python Turtle Module (Turtle Library)

We are drawing with this module, which comes ready with the Python programming language. We can make geometric shapes or free drawings with the functions contained in them. Some functions related to this module are described below.

We can import the Turtle module into our Python pages and make drawings with the drawing functions contained in it. To import this module,the following line of Code must be written first.

import turtle
or
from turtle import *

turtle.forward( ) fonksiyonu.

Draws a line in the pixel value written in parentheses forward.
turtle.forward(100)

turtle.left ( ) fonksiyonu:

It rotates to the left around itself in the ratio of the angle written to the inside of the parenthesis.

turtle.left(90)      //90 derece sola döner

turtle.right( ) fonksiyonu:

It rotates to the right around itself in the ratio of the angle written in brackets.
turtle.right(90)      //90 derece sağa döner

turtle.pensize ( ) fonksiyonu:

This function adjusts the thickness of the pen. Thickens the pen as much as the value written in parentheses.
turtle.pensize(10)

turtle.circle ( ) fonksiyonu:

Draws a circle in the unit written in parentheses.
turtle.circle(100)

Some functions also used in Turtle:

Function name-usage description

forward (100) draw 100 units forward line
backward (50) draw 50 units back line
left (60) 60 degrees turn left
right (90) 90 degrees turn right
pensize (10) Make pen tip thickness 10 units
color(“red”,”yellow”) make the line color red, the fill color yellow
begin_fill () start painting
end_fill () finish painting
circle (50) draw a circle of 50 units
speed (1) set turtle speed(1 Slow-10 fast)
penup() lift the pen to
pendown() Pen Press
goto (100,200) go to the coordinate x =100 ,y =200 in the window
clear () clear screen

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *