Watching this video to understand how we use loops in real-world programming.
In the previous lesson, we learned about for loops and while loops and how they world. However, what are the real-world applications of loops? Why would we want to use loops? Here are some examples.
At first, we dive into using a for loop to create related lists. If we have a list of numbers and we want to find the square of all those numbers, we can use a for loop to iterate over the original list.
Then, we look at using a for loop to iterate over numbers from 0 to n-1, using the range keyword.
Finally, we explore a use case of a while loop in order to find the base-2 log of some number n.
Timestamps:
00:00 Intro
00:14 Building Related Lists
05:12 Iterating Numbers
07:05 Looping over Indices
10:14 Implementing Log2
Feel free to leave any questions.
Please consider subscribing if you liked this video: https://www.youtube.com/c/ycubed?sub_...
Thanks for watching everyone!
~~~~~~~~~~~~~~~~~~~~~~~~
Follow me on Instagram: / kylieyying
Follow me on Twitter: / kylieyying
Check out my website: https://www.kylieying.com