0% found this document useful (0 votes)
62 views6 pages

Turtlecodes

This Python code uses the turtle module to draw shapes and letters on a canvas. It defines functions to control the turtle's movement and drawing. The code sets the background color, then draws a loop of triangles. It draws the letter P by filling and outlining it. Similarly, it draws the letter A and the letter T by filling and outlining. It then draws the numbers 1003. Finally, it draws 5 colored stars in different locations on the canvas before ending the program.

Uploaded by

api-327820167
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views6 pages

Turtlecodes

This Python code uses the turtle module to draw shapes and letters on a canvas. It defines functions to control the turtle's movement and drawing. The code sets the background color, then draws a loop of triangles. It draws the letter P by filling and outlining it. Similarly, it draws the letter A and the letter T by filling and outlining. It then draws the numbers 1003. Finally, it draws 5 colored stars in different locations on the canvas before ending the program.

Uploaded by

api-327820167
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import turtle

turtle.shape("turtle")

turtle.speed(10)
turtle.width(5)
turtle.left(90) #heads upward

#===================================================================
#Settings
def FW(distance):
turtle.forward(distance)

def BW(distance):
turtle.backward(distance)

def R(angle):
turtle.right(angle)

def L(angle):
turtle.left(angle)

def MoveL(distance):
turtle.left(90)
FW(distance)

def MoveR(distance):
turtle.right(90)
FW(distance)

def MoveRU(angle,distance):
R(angle)
FW(distance)

def MoveLU(angle,distance):
L(angle)
FW(distance)

def drawLoopTri(x,y):
turtle.speed(100)
for times in range(x):
for triangle in range(3):
FW(400)
L(y)
turtle.speed(10)

def drawLoopCir(times,largeness): #Unused


turtle.speed(50)
for time in range(times):
for circle in range(360):
FW(largeness)
L(1)
turtle.speed(10)

def pd():
turtle.pendown()

def pu():
turtle.penup()

def drawP():
FW(250)
MoveRU(45, 50)
MoveRU(45, 100)
MoveRU(90, 100)
MoveRU(45, 50)
MoveRU(45, 60)
MoveL(100)
MoveRU(45,80)

def drawA():
turtle.setheading(225)
FW(100)
BW(100)
turtle.setheading(90)
FW(200)
MoveR(105)
MoveRU(60,60)
MoveRU(30,50)
MoveR(170)
BW(170)
L(90)
FW(100)

def drawT():
turtle.setheading(90)
FW(240)
MoveL(200)
MoveR(50)
MoveR(330)
MoveR(50)
MoveR(70)
MoveL(240)
MoveR(60)

def starA(line):
turtle.setheading(90)
MoveL(line/2)
R(180)
for times in range(5):
FW(line)
R(145)

#===================================================================
#Background
turtle.bgcolor("#fffcb7")

pu()
turtle.setx(100)
turtle.sety(-100)

pd()
turtle.color("#7caeff")
drawLoopTri(20,130)
pu()

#================================
#Letter P Filling

turtle.setx(-250)
turtle.sety(-200)

turtle.setheading(90)
pd()
turtle.color("#ffb254")
turtle.begin_fill()
drawP()
turtle.end_fill()
pu()

#================================
# Letter P Linework
turtle.setx(-250)
turtle.sety(-200)

turtle.setheading(90)
pd()
turtle.width(10)
turtle.color("#e28636")
drawP()
FW(50)
turtle.width(5)
pu()

#================================
#Letter A
turtle.setx(-70)
turtle.sety(-200)

turtle.setheading(90)
pd()
turtle.color("#59aa31")
turtle.width(20)
drawA()

#================================
#Letter T Filling

turtle.width(10)
MoveL(40)
turtle.color("#a18eff")
FW(50)

turtle.begin_fill()
drawT()
turtle.end_fill()

#================================
#Letter T Linework

turtle.color("#7054ff")
turtle.width(15)
drawT()
pu()

#================================
#1003
turtle.width(5)
turtle.color("#ffbb00")
turtle.goto(-300,280)
pd()
#Number 1
turtle.setheading(0)
FW(5)
MoveR(20)
MoveR(5)
turtle.setheading(0)
FW(10)
pu()
FW(10)

Number 0s
#
def drawzero():
pd()
FW(10)
for times in range(2):
MoveL(20)
MoveL(10)

pu()
FW(10)

drawzero()
drawzero()

#Number 3
pd()
FW(10)
for times in range (2):
MoveL(10)
R(180)
FW(10)
for times in range (2):
MoveL(10)
pu()
#================================

# STARS
turtle.goto(0,250)
turtle.color("#ff3a3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

turtle.goto(-100,250)
turtle.color("#ff993a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

turtle.goto(100,250)
turtle.color("#f8ff3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

turtle.goto(-50,200)
turtle.color("#58ff3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()
turtle.goto(50,200)
turtle.color("#3abdff")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

#================================
turtle.exitonclick()

You might also like