<jupyter_start><jupyter_text>LoopsLoops let you execute code over and over.  Basic Loops  PredictWhat will this code do?<jupyter_code>for i in range(10):
    print(i)
for i in range(15):
    print(i)<jupyter_output><empty_output><jupyter_text>SummarizeWhat does the `range` function do?   ModifyChange the cell below so it prints all $i$ between 0 and 20.<jupyter_code>for i in range(11):
    print(i)<jupyter_output><empty_output><jupyter_text>Implement Write a loop that calculates the sum:$$ 1 + 2 + 3 + ... + 1001$$  Loops with conditionals  PredictWhat will this code do?<jupyter_code>for i in range(10):
    if i > 5:
        print(i)<jupyter_output><empty_output><jupyter_text>ModifyChange the code below so it goes from 0 to 20 and prints all `i` less than 8.<jupyter_code>for i in range(10):
    if i > 5:
        print(i)<jupyter_output><empty_output><jupyter_text>PredictWhat will this code do?<jupyter_code>for i in range(10):
    if i > 5:
        break
    print(i)<jupyter_output><empty_output><jupyter_text>SummarizeWhat does the `break` keyword do?  PredictWhat will this code do?<jupyter_code>for i in range(10):
    print("HERE")
    if i > 5:
        continue
    print(i)<jupyter_output><empty_output><jupyter_text>SummarizeWhat does the `continue` keyword do?  ImplementWrite a program that starts calculating the sum:$$1 + 2 + 3 + ... 100,000$$but stops if the sum is greater than 30,000.<jupyter_code>x = 0
for i in range(1,100001):
    x = x + i
    if x > 30000:
        break<jupyter_output><empty_output><jupyter_text>While loops  PredictWhat will this code do?<jupyter_code>x = 1
while x < 10:
    print(x)
    x = x + 1<jupyter_output><empty_output><jupyter_text>PredictWhat will this code do?<jupyter_code>x = 1000
while x > 100:
    print(x)
    x = x - 10<jupyter_output><empty_output><jupyter_text>SummarizeHow does `while` work?  ModifyChange the following code so it will print all values of $x^2$ for $x$ between 5 and 11.<jupyter_code>x = 0
while x < 20:
    print(x*x)
    x = x + 1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10580204778156997, 'fraction_numerical': 0.03900536323744515, 'mean_word_length': 4.3858267716535435, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '219583', 'license': 'Unlicense', 'n_tokens_mistral': 821, 'n_tokens_neox': 751, 'n_words': 218, 'path': 'chapters/00_inductive-python/04_loops.ipynb', 'repo_name': 'lperezmo/pythonic-science', 'size': '2051'}