One Pager Cheat Sheet
- In this lesson, we will learn about loops and iterations in programming, to automate the process of applying operations to collections of elements.
- Iteration and iterablessuch aslistsandstringsare key concepts in programming which can be implemented through the use of loops.
- Loopsare a programming structure used for- iterationthat are usually implemented with- forand- whileloops in different programming languages.
- Forloops are used to iterate over a sequence of elements, either using the- rangekeyword to specify the number of repetitions or directly accessing elements in an iterable.
- Whileloops are used to iterate over a sequence of elements until a certain condition is met, typically by initializing a variable before the start of the loop and using- unaryoperators to increment or decrement the value of the variable.
- The forloop will iterate through the listfruits(which contains 6 elements) and print each element per iteration, resulting in the loop being executed 6 times.
- The code will generate an error because range()expects an integer as the argument, not a list.
- One must be careful to use the breakandcontinuestatements correctly to avoid anInfinite loop, as forcing an execution stop is the only way to terminate it.
- The code prints all the letters in "Loops" exceptfor 'o', which was skipped due to thecontinuestatement in thewhileloop, leaving 'p' as the last character.
- The whileloop will continueindefinitelyas long as the conditiona <= 5isTrue.
- Iterations are an important concept in programming that helps us reduce code quantity and promote code reusability and modularity by allowing us to specify the number of times a code block needs to be repeatedorconditionsthat specify its reuse.



