Lesson 1,
Topic 1
In Progress
Activity 1: Check Perfect Squares
A perfect square is a number that can be expressed as the product of an integer by itself. Like 9, 25, 100, etc.
Let’s look at the flowchart to identify if a number is a perfect square or not:
Let’s take the example for 9.
- Loop 1:
- Count = 1
- Square = 1
- Square < 9 – Restart the loop
- Loop 2:
- Count = 2
- Square = 4
- Square < 9 – Restart the loop
- Loop 3:
- Count = 3
- Square = 9
- Perfect Square
Let’s take another example for 12.
- Loop 1:
- Count = 1
- Square = 1
- Square < 12 – Restart the loop
- Loop 2:
- Count = 2
- Square = 4
- Square < 12 – Restart the loop
- Loop 3:
- Count = 3
- Square = 9
- Square < 12 – Restart the loop
- Loop 4:
- Count = 4
- Square = 16
- Square > 12 – Not a perfect Square
Code
Let’s write the code for the flowchart.
- Create three variables:
- Number: To store the number we are checking for a perfect square.
- Count: To keep track of loop counts
- Square: To calculate the square in the loop.
- Get the Number from the user, using ask and wait block.
- Set Count to 1.
- Add the repeat () block and add round (Number /2) in the condition.
- In the loop, set the Square as Count * Count.
- Now add an if () block and check if Number = Square. If yes display the message and stop the program with stop () block from the Control palette.
- Next, add another if () block and check if Number < Square. If yes display the message and stop the program with stop () block from the Control palette.
- Finally, add change (Count) by 1 below the last if () block.
Your script is complete.
Click the green flag to check the code.
Assignment
Before you move on to the next lesson, a small assignment awaits you!
You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.
Follow the steps below to upload your assignment:
- Click on Choose File.
- Select the image from the pop-up window that opens up.
- Once the image is selected, click on Upload Assignment.

The file type allowed is the SB3 file generated from the PictoBlox program. The maximum file size allowed is 5 MB.
Good luck!