Activity 2: Drawing a Shape by Inputting the Number of Sides

In lesson 3, we made individual scripts for drawing individual shapes. What if we could make just one that can draw any shape?

Pentagon

Using operators we can! Let’s do it:

  1. Import the Pen sprite and set the backdrop.
    Pen and stage
  2. Adjust the center of the pen to tip.
  3. Next, make a variable named Sides and set its input as 5.
  4. Then, add a repeat block and drag and drop the Sides variable block inside the space of the repeat block. Placing the Sides variable block in the space indicates that the repeat block will make the script inside it repeat as many times as the value of Sides.
  5. Now, we need to decide the value of the angle. We’ll write this formula using the () / () (division operator) block and the Sides variable block. Click on Operators palette and drag and drop a () / () block inside the space of the move () steps block. According to the formula, you must divide 400 by the number of sides of the shape. Therefore, in the left space of the () / () block write 400, and in the right space, drag and drop the Sides block.
  6. Next, drag and drop the turn clockwise () degrees block from the Motion palette and repeat step 6.
  7. Now, go to the Control palette and add a wait () secs block below the move () steps block; set the time as 0.1 seconds.
  8. Complete the script by adding a when (d) key clicked block.

Below is the complete script:

Pentagon Script

Pentagon

Assignment

Before you move on to the next lesson, a small assignment awaits you!

You must upload the PictoBlox program you wrote in the Activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.

Submitting the assignment is a must in order to receive the certificate after completing the course.

Follow the steps below to upload your assignment:

  1. Click on Choose File.
  2. Select the image from the pop-up window that opens up.
  3. Once the image is selected, click on Upload Assignment.
evive Alert
File types allowed is SB3 file generated from the PictoBlox program. The maximum file size allowed is 5 MB.

Good luck!

×
×

Cart

ENROLL FOR YOUR FREE DEMO SESSION