0% found this document useful (0 votes)
31 views

Import Turtle

The document uses the turtle module to draw a ninja figure. It creates a Turtle object called ninja and sets its speed to 10. It then uses a for loop and sequences of forward, right, and left movements to draw the outline of the ninja in green. It further draws components like arms and stars in yellow, red, and gold using begin_fill and end_fill to color in shapes.

Uploaded by

api-350453759
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Import Turtle

The document uses the turtle module to draw a ninja figure. It creates a Turtle object called ninja and sets its speed to 10. It then uses a for loop and sequences of forward, right, and left movements to draw the outline of the ninja in green. It further draws components like arms and stars in yellow, red, and gold using begin_fill and end_fill to color in shapes.

Uploaded by

api-350453759
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import turtle

ninja = turtle.Turtle()

ninja.speed(10)

for i in range(180):
ninja.forward(100)
ninja.right(30)
ninja.forward(20)
ninja.left(60)
ninja.forward(50)
ninja.right(30)

ninja.penup()
ninja.setposition(0, 0)
ninja.pendown()

ninja.right(2)

ninja.penup()
ninja.goto(-170, -50)

ninja.pendown()

ninja.penup()
ninja.forward(10)
ninja.pendown()

ninja.pensize(15)

ninja.color("green")
ninja.left(90)
ninja.forward(100)
ninja.right(120)
ninja.forward(50)
ninja.left(60)
ninja.forward(50)
ninja.right(120)
ninja.forward(100)

ninja.penup()
ninja.left(90)
ninja.forward(25)

ninja.penup()
ninja.goto(-170, -50)

ninja.pendown()

ninja.penup()
ninja.forward(10)
ninja.pendown()

ninja.pensize(15)

ninja.color("green")
ninja.left(90)
ninja.forward(100)
ninja.right(120)
ninja.forward(50)
ninja.left(60)
ninja.forward(50)
ninja.right(120)
ninja.forward(100)

ninja.penup()
ninja.left(90)
ninja.forward(25)

ninja.color("yellow")
ninja.pendown()
ninja.left(65)
ninja.forward(110)
ninja.right(125)
ninja.forward(110)

ninja.penup()
ninja.left(60)
ninja.forward(25)

ninja.color("red")
ninja.pendown()
ninja.left(90)
ninja.forward(100)
ninja.right(120)
ninja.forward(50)
ninja.left(60)
ninja.forward(50)
ninja.right(120)
ninja.forward(100)

ninja.penup()
ninja.forward(200)
ninja.right(90)
ninja.forward(325)
ninja.right(90)

ninja.pensize(5)

ninja.color("gold1")
ninja.begin_fill()
ninja.pendown()
ninja.forward(150)
ninja.right(90)
ninja.forward(25)
ninja.right(90)
ninja.forward(150)
ninja.end_fill()

ninja.penup()
ninja.left(90)
ninja.forward(25)

ninja.color("gold2")
ninja.begin_fill()
ninja.pendown()
ninja.forward(100)
ninja.left(90)
ninja.forward(150)
ninja.left(90)
ninja.forward(100)
ninja.left(90)
ninja.forward(150)
ninja.end_fill()

ninja.penup()
ninja.left(90)
ninja.forward(125)

ninja.color("gold3")
ninja.begin_fill()
ninja.pendown()
ninja.forward(100)
ninja.left(90)
ninja.forward(150)
ninja.left(90)
ninja.forward(100)
ninja.left(90)
ninja.forward(150)
ninja.end_fill()

ninja.penup()
ninja.left(90)
ninja.forward(125)

ninja.color("gold4")
ninja.begin_fill()
ninja.pendown()
ninja.left(90)
ninja.forward(150)
ninja.right(90)
ninja.forward(25)
ninja.right(90)
ninja.forward(150)
ninja.end_fill()

turtle.done()

You might also like