Many thoughts came to my mind as I thought about Fancy shapes using Nested loops, mentioned here as this blog’s title. As we are already aware of loops we can also understand the term nested loop. Well if you are a computer science student then this will be just a cup of tea for you. Loop is a one of the basic structures of programming. A loop is a sequence of instructions that is continuously repeated until a certain condition is reached whereas a nested loop is a loop within a loop, an inner loop within the body of an outer one.
As you can see Limited blocks are given to run the program. As of now we have to execute our own programming to see whether it works or not. Already the title suggests that we have to create programming by using nested loops.
As you can see in picture there are 6 shaded squares attached but a gap is there between them. In blocks we can see that the Move Forward block can be used only one time . Now read the instruction where it is mentioned about the pixel for sides , degree for angles , how much you need to turn and jump to complete the programming.
So, let's start working on it step by step with pictures.
Step 1 - To complete one square you have to add Move forward and turn left block after when run block. Only 1 move forward block can be used at a time, so to complete a square repeat loop is necessary so add a repeat block by repeating the process 4 times. Run the program and see whether your command is correct or not.
Step 2 - After completing a square box another 5 shaded squares are left. Now you have to use the jump forward block and turn right block i.e jump forward by 50 pixel and turn right by 60 degrees. Now again run the program and see the progress or else you can also try turn left block and try to run programming in both manner. You will find error in one of the procedures but try it once it's fun trying various methods to solve the programming.
Step 3 - As you can see the progress in the picture itself. Now for completing another squares you need to repeat the same procedure for that we have to use a loop block again. Repeating the same process 6 times to complete all the squares. Here nested loop is used i.e a loop within a loop. Run the program again.
While running the program it is not necessary that you may be able to solve it in one attempt or more then that but it will be fun for your children to try and understand it. After seeing this procedure step by step you might be now able to get an idea about nested loops. It will make your child understand and well it's fun loving once you start solving it.
It’s easy once you do it, try it once…. Link given below just click on it and try to solve the exercise.