GRAPHICS USING PYTHON TURTLE MODULE

GRAPHICS USING PYTHON TURTLE MODULE

If you need to draw geometric diagrams in python, then turtle is a good module which can create different figures with respect to different angles.

A small turtle pointer acts as a pen which can draw the figures as per our definition.

turtle has many methods which can used to control the shape of the figures

import turtle

turtle.shape("turtle")

turtle.exitonclick()

import turtle

turtle.shape("turtle")

for X in range(0,10):
    turtle.forward(80)
    turtle.right(45)

for Y in range(0,10):
    turtle.forward(80)
    turtle.left(90)

for X in range(0,10):
    turtle.forward(80)
    turtle.right(45)

turtle.exitonclick()

import turtle

for X in range(0, 10):
    turtle.right(45)
    for X in range(0, 5):
        turtle.forward(100)
        turtle.right(90)
turtle.exitonclick()

Leave a Reply

%d