14.1: The Two Species of Loops

The Crystal Ball - Instruction Manual I: Introduction to Data Science · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-SA 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    14.1: The Two Species of Loops

    Although some programming languages try to dress them up further, there are really only two fundamental kinds of loops in the world: fixed-iteration loops and variable-iteration loops.1 The first kind is simpler to understand and less error-prone; in most languages (Python included) it is implemented as a “for loop.” The tricker, second kind is available to programmers as a “while loop.”

    Happily for us, it turns out that while loops don’t come up much in Data Science, at least in the beginning. There are some more advanced techniques that use them (for instance, optimization methods and threshold detection) but for us it’s going to be for loops that dominate the landscape. So let’s figure out how they work.


    This page titled 14.1: The Two Species of Loops was last modified on Sun, 18 Sep 2022 02:06:12 GMT and is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Stephen Davies (allthemath.org) via source content that was edited to the style and standards of the LibreTexts platform.