xxxxxxxxxx
import turtle # imports the turtle module.
whateveruwanttocallit = turtle.Turtle()
whateveruwanttocallit.fd(10) # moves forward by whatever you put in
whateveruwanttocallit.lt(90) # turns left whatever degrees you put in
whateveruwanttocallit.rt(90) # turns right whatever degrees you put in
whateveruwanttocallit.color('red') # the color
whateveruwanttocallit.up() # lifts the pen up
whateveruwanttocallit.down() #puts the pen down
#you can also import turtle as t to make the 'whateveruwanttocallit' just
#written as t. you can also skip the turtle.Turtle() part.
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
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
# 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 package
import turtle
# Creating a turtle object(pen)
pen = turtle.Turtle()
# Defining a method to draw curve
def curve():
for i in range(200):
# Defining step by step curve motion
pen.right(1)
pen.forward(1)
# Defining method to draw a full heart
def heart():
# Set the fill color to red
pen.fillcolor('red')
# Start filling the color
pen.begin_fill()
# Draw the left line
pen.left(140)
pen.forward(113)
# Draw the left curve
curve()
pen.left(120)
# Draw the right curve
curve()
# Draw the right line
pen.forward(112)
# Ending the filling of the color
pen.end_fill()
# Defining method to write text
def txt():
# Move turtle to air
pen.up()
# Move turtle to a given position
pen.setpos(-68, 95)
# Move the turtle to the ground
pen.down()
# Set the text color to lightgreen
pen.color('lightgreen')
# Write the specified text in
# specified font style and size
pen.write("GeeksForGeeks", font=(
"Verdana", 12, "bold"))
# Draw a heart
heart()
# Write text
txt()
# To hide turtle
pen.ht()