Python Turtle

Turtle is a Python library to draw different graphical shapes.
Turtle Library

Turtle library in Python to draw graphic shapes like triangles, squares , stars multiple shapes


Start with one line
import turtle
my_w=turtle.Turtle()
my_w.forward(200) # draw line of 200px distance 
turtle.done()

Triangle

Triangle using Turtle
import turtle
my_t = turtle.Turtle()

my_t.forward(200)
my_t.right(-120)
my_t.forward(200)
my_t.right(-120)
my_t.forward(200)

turtle.done()

Square

Square using Turtle
import turtle
my_t = turtle.Turtle()
 
my_t.forward(200)
my_t.right(-90)
my_t.forward(200)
my_t.right(-90)
my_t.forward(200)
my_t.right(-90)
my_t.forward(200)
     
turtle.done()

Hexagon

Hexagon using Turtle
import turtle
my_t = turtle.Turtle()
for i in range (6):
    my_t.forward(100)
    my_t.right(-60)
     
turtle.done()

Drawing star

Star using Turtle
import turtle
my_w=turtle.Turtle()

for i in range(8):
    my_w.forward(200)
    my_w.right(135)

turtle.done()

Multiple stars

Multiple Stars using Turtle
import turtle
my_w=turtle.Turtle()

for i in range(24):
    my_w.forward(200)
    my_w.right(165)

turtle.done()

Multiple triangles

Multiple triangles using Turtle
import turtle
my_t = turtle.Turtle()
turtle.colormode(255)
#turtle.speed(9)
x=20
r,g,b=10,10,10
d=2
for i in range (48):
    my_t.pencolor(r,g,b)
    my_t.forward(x)
    my_t.right(120)
    r=r+d
    x=x+5 
turtle.done()

Multiple Squares

Multiple Squares using Turtle
import turtle
my_t = turtle.Turtle()
turtle.colormode(255)
#turtle.speed(9)
x=20
r,g,b=10,10,10
d=2
for i in range (48):
    my_t.pencolor(r,g,b)
    my_t.forward(x)
    my_t.right(90)
    r=r+d
    x=x+5 
turtle.done()

Projects using Tkinter
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer