The power of LOOPS — how can we use them?

Loops. What do you think of when you hear loops? You might think about codes, programs, and functions…..but that’s not just all. Loops are more than just THAT, they are not just part of a program, well, they are, but they can be used on important technologies too.

Loops can be used in programming TONS of high techs, and today, I’m going to use a fire-detecting, self-driving drone as an example. First of all, we need to make sure that it remembers to avoid objects ALL the time, we can put this code in a loop. We can put the “avoid objects” code in a loop that runs forever, so the drone wouldn’t find itself tangled in power lines at anytime. Secondly, we have to make sure that its fire-detecting “body” works every time. We can also put this code in a loop, so it’ll remember to run.

For my second example, I’m going to use a tiny robot insect that goes into your body to detect and kill cancer cells. For this robot, we need lots of loops to make this complex program easier to code. The first loop we might use is to make sure it “moves”, I mean, we can’t just put 100,000,000 move forward codes so it’ll move 100,000,000 steps JUST to program this robot, that’ll be very time-wasting. To make things much simple, we can put the “move forward” code inside a loop that runs for 100,000,000 times, that’s a huge number, but at least we don’t have to repeat it for THAT many times. Another way to use loops in this robot’s program is to make sure that it kills cancer cells whenever it sees one, so we’ll have to put it in a loop that says “kills cancer cells until program ends”.

Loops make coding easier, and these two technologies are just few of the many examples on how we can use loops. Now that you know loops can be used on SO many things, next time when you hear “loop”, you better NOT just think about functions.

Show your support

Clapping shows how much you appreciated Katherine Yu’s story.