xxxxxxxxxx
import turtle
#creating a square with turtle
t = turtle.Turtle()
t.forward(100)
t.color('blue')
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
xxxxxxxxxx
import turtle
colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
t = turtle.Pen()
turtle.bgcolor('black')
for x in range(360):
t.pencolor(colors[x%6])
t.width(x//100 + 1)
t.forward(x)
t.left(59)
xxxxxxxxxx
# Python program to draw square
# using Turtle Programming
import turtle
skk = turtle.Turtle()
for i in range(4):
skk.forward(50)
skk.right(90)
turtle.done()
xxxxxxxxxx
import turtle # imports it
whateverYouWantToCallIt = turtle.Turtle() # adds it to the project
#code
whateverYouWantToCallIt.forward(10) # moves whateverYouWantToCallIt forward
whateverYouWantToCallIt.color("purple") # color
whateverYouWantToCallIt.left(90) # turns him 90 degrees
whateverYouWantToCallIt.right(90) # turns him 90 degrees the other direction
xxxxxxxxxx
>>> turtle.position()
(0.00,240.00)
>>> turtle.setx(10)
>>> turtle.position()
(10.00,240.00)
xxxxxxxxxx
import turtle
myTurtle = turtle.Turtle()
myTurtle.forward(100)
myTurtle.right(90)
myTurtle.forward(100)
xxxxxxxxxx
import turtle
a = turtle.Turtle()
a.color("orange")
a.begin_fill()
for i in range (1,11):
a.forward(36)
a.left(36)
a.end_fill()
a.right(90)
a.forward(30)
a.color("red")
a.write("Decagon")
a.forward(25)
xxxxxxxxxx
# import turtle library
import turtle
my_window = turtle.Screen()
my_window.bgcolor("blue") # creates a graphics window
my_pen = turtle.Turtle()
my_pen.forward(150)
my_pen.left(90)
my_pen.forward(75)
my_pen.color("white")
my_pen.pensize(12)
xxxxxxxxxx
#import turtle
import turtle
b=turtle.Pen()
b.speed(50)
for i in range(4):
for i in range(4):
for i in range(4):
for i in range(8):
for i in range(3):
for i in range(6):
b.fd(10)
b.lt(60)
b.lt(120)
b.fd(30)
for i in range(2):
b.lt(90)
b.fd(30)
b.lt(-90)
b.fd(10)
b.fd(90)
b.fd(200)
b.lt(90)