...

Draw a Penguin

In this class, students will learn Turtle graphics in Python, including essential functions, coordinate manipulation, and step-by-step instructions to draw a penguin.
As part of this project you will learn:


  •     Turtle graphics library
  •     Learn about essential functions in Turtle
  •     Work with coordinates on the screen
  •     Draw a penguin

Step 1: Let's start coding
  • In your logged-in trinket account click on New Trinket -> Python

  • Or Open the blank Python template trinket: Open New.

  • What is Turtle library?

    In Python, a library is a reusable chunk of code you can include in your programs and use pre-existing functionality.

    Turtle is a graphic library for Python. Using Turtle, we can easily draw in a drawing board.

  • The first step is to import the Turtle module. Place import statements at the top of your code.
  • Next, define the screen and specify its dimension. Type the code as follows:
  • done() command must be the last statement in a turtle graphics program.
  • Let's add the background colour to the screen. Follow the code below:
  • The hideturtle() command will hide the cursor

  • Next
    Step 2: Explore Turtle Functions

    Now, let's explore some essential Turtle functions. We'll start by drawing a circle and filling it with a colour.
    We will use the following commands:

  • speed(number) - set the speed of your drawing from 0 to 10
  • penup() - This command lifts the turtle's writing pen, so it won't leave a trace while moving.
  • pendown() - With this command, we put the turtle's writing pen back down, allowing it to draw on the screen.
  • goto(x,y) - Use this command to navigate the turtle to a specific coordinate on the screen. The (x, y) values represent the horizontal and vertical positions.
  • color("colourName") - This command sets the colour of the turtle's pen or fill to the specified colour name, such as "blue" in our case.
  • begin_fill() and end_fill() - These commands mark the beginning and end of the shape that we want to fill with the selected colour.
  • forward(number) - Use this command to move the turtle forward by a specified number of pixels.
  • right(angle) and left(angle) - These commands allow the turtle to turn right or left by the specified angle.

  • Type the code as follows:

    Prev Next
    Step 3: Draw the rectangle

    To draw the rectangle, follow these steps:

  • Use the goto(x, y) command to position the turtle at the starting position where you want to draw the rectangle.
  • Select a color using the color("colour name") command. Choose any color you like!
  • Draw a line by moving the turtle forward with the forward(number) command. Specify the length of the line by providing a number.
  • To create a right angle turn, use either right(90) or left(90) command. This will rotate the turtle by 90 degrees.
  • Repeat steps 3 and 4 three more times to complete the rectangle.
  • Here's an example code to help you draw the rectangle:

    Prev Next
    Step 4: Start your drawing
  • Create a new trinket
  • The first step is to import the Turtle module. Place import statements at the top of your code.
  • Set the drawing speed to 0 (fastest speed).
  • Prev Next
    Step 5: Draw the penguin body.

    Draw the penguin body.

    Draw the penguin belly.

    Prev Next
    Step 6: Draw the penguin face

    Draw the penguin's nose.

                            
                                # Nose
                                pu()
                                goto(60, 80)
                                pd()
                                color("orange")
                                stamp()
    
                            
                        

    Draw the penguin's eyes.

                            
                                # Eye 1
                                pu()
                                goto(30, 110)
                                pd()
                                color("white")
                                shape("circle")
                                stamp()
                                color("black")
                                begin_fill()
                                circle(5)
                                end_fill()
                                
                                # Eye 2
                                pu()
                                goto(90, 110)
                                pd()
                                color("white")
                                stamp()
                                color("black")
                                begin_fill()
                                circle(5)
                                end_fill()
                            
                          

    Prev Next
    Step 7: Draw arms and legs

    Draw the penguin's arms.

                    
                        # Arms
                        pu()
                        goto(0, 50)
                        pd()
                        shape("triangle")
                        color("black")
                        stamp()
                        goto(120, 50)
                        stamp()
    
                    
                

    Draw the penguin's legs.

                
                    # Legs
                    shape("square")
                    color("orange")
                    pu()
                    goto(45, -60)
                    pd()
                    stamp()
                    goto(80, -60)
                    stamp()
                
            
    Prev Next
    Please ensure all required fields are filled in
    Step 8: The complete code

    Once you run this code, it should create a cute penguin drawing using the Turtle graphics library in Python. Your code should be similar to this:

    Prev Next
    Please ensure all required fields are filled in
    Step 9: Save your work

  • If you don't have a Trinket account, click the down arrow and then click Link. This will give you a link that you can save and come back to later.
  • If you have a Trinket account, you can click Remix to save your own copy of the trinket.
  • Prev Next
    Complete and Share

    Submit your final project



    Copy your Trinket Url

  • Click Share->Link
  • Copy the link to share your code
  • Paste link into the field
  • Prev