Coding an App: Perfect Squares and Square Roots

Coding an App: Perfect Squares and Square Roots

In this activity we will build an app that 1) generates the first 10 perfect squares and 2) prompts the user to determine the square root of one of them, chosen at random.


To begin, create a variable. I have named mine counter. Set counter to 1 to begin and setup the loop structure as seen above. Your loop will loop 10 times, multiply counter by itself each time, and then increment counter by 1.

Essentially it looks like this when it runs:

1 * 1

2 * 2

3 * 3


Next, chose a random number between 1 and 10. This will refer to the row number of our list.



Prompt the user to input the square root of the randomly chosen perfect square, set up the math structure and give it a try!



To see it in action check out the video below:

Try it for yourself:

Project page:

For more lessons, activities and ideas, grab a copy of my book, Code Breaker, on Amazon here!

(Visited 2,647 times, 1 visits today)

Leave a Reply

Email *