<jupyter_start><jupyter_text>Exercise 2Add the specified code for each code cell, running the cells _in order_. Write a **`for`** loop that prints out every 5th number (multiples of 5) from 0 to 100 (inclusive).- _Tip:_ use an **`end=','`** keyword argument to the `print()` function to print all the numbers on the same line.<jupyter_code>a = 0
for a in range(0, 100, 5):
    print(a, end=',')<jupyter_output>0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,<jupyter_text>Use a **`for`** loop to print out the first 15 [Triangular numbers](https://en.wikipedia.org/wiki/Triangular_number). This is a sequence of numbers for which the _nth_ value is the sum of the numbers from 0 to _n_. **Do this only using addition!**- _Hint:_ use an additional variable to keep track of the `total` value, and have that value increase by the number of times you've been through the loop each iteration!<jupyter_code>a = 0 
n = 0
for n in range(0, 15):
    a = a + n
    print(a, end=',')<jupyter_output>0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,<jupyter_text>_Challenge_ Use a **`for`** loop to print out 20 numbers, each of which is larger than the previous by the the _sum_ of the **two** previous numbers (the [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number).- _Hint_: you'll need to keep track of the two previous values (start them at 0 and 1), and then "update" them each time through the loop, storing the  "new total" in the first previous variable, and the first previous variable in the second (be careful about the ordering of this!)<jupyter_code>a = 0
b = 1
for n in range(0, 20):
    print(b, end=',')
    sum = a + b
    a = b
    b = sum<jupyter_output>1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,<jupyter_text>Define a function **`is_prime()`** that takes in a whole number as an argument and returns whether or not that number is prime (divisible by only 1 and itself).- You can check divisibility by seeing if the remainder (using the modulo **`%`** operator) is 0, or by comparing the integer of the quotient to the float of the quotient.- Be careful to only `return` that a value is in fact prime after you've checked **all** the factors!<jupyter_code>def is_prime(num:int):
    for n in range(2, num):
        if num % n == 0:
            return False
    return True
is_prime(2)<jupyter_output><empty_output><jupyter_text>Define a function **`find_primes()`** that takes in a whole number and _prints out_ all of the prime numbers that are less than or equal to the parameter. Call the function to print out the prime numbers up to 101.- Make sure to your `is_prime()` function!<jupyter_code>def find_primes(num:int):
    for n in range(2, num):
        if is_prime(n):
            print(n, end=',')
find_primes(102)<jupyter_output>2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,<jupyter_text>As discussed in the course text, `for` loops can be used to iterate over collections of data such as files. But it is also possible to convert a **`string`** into a collection (technically a _list_) of ___words___ by calling the [split()](https://docs.python.org/3.6/library/stdtypes.htmlstr.split) method on that string.Create a variable `quote` containing a quote from someone you admire. Then create a variable **`words`** by calling the `split()` method on the quote.<jupyter_code>quote = "Without an acquaintance with the rules of propriety, it is impossible for the character to be established."
words = quote.split(" ")
print(words)<jupyter_output>['Without', 'an', 'acquaintance', 'with', 'the', 'rules', 'of', 'propriety,', 'it', 'is', 'impossible', 'for', 'the', 'character', 'to', 'be', 'established.']<jupyter_text>Use a **`for`** loop to iterate through the words, printing out each one on a separate line.<jupyter_code>for word in words:
    print(word)<jupyter_output>Without
an
acquaintance
with
the
rules
of
propriety,
it
is
impossible
for
the
character
to
be
established.<jupyter_text>Use a **`for`** loop to determine the _percentage_ of words in the quote that have 4 or more letters.<jupyter_code>total_words = 0
count_4 = 0
for word in words:
    total_words += 1
    if len(word) >= 4:
        count_4 += 1
ratio = count_4 / total_words * 100
print("The percentage is " + str(ratio) + " %")<jupyter_output>The percentage is 47.05882352941176 %<jupyter_text>It's also possible to use a `for` loop to iterate through the _letters_ in a string!Create a variable `word` containing your favorite word. Iterate through the letters in the word, printing `"Give me a __!"` for each (replacing the `__` with the letter). Finally, print `"What does that spell?!"` followed by the word.<jupyter_code>word = "Five"
for letter in word:
    print("Give me a " + letter +" !")
print("What does that spell?! ", word.upper())<jupyter_output>Give me a F !
Give me a i !
Give me a v !
Give me a e !
What does that spell?!  FIVE
{'fraction_non_alphanumeric': 0.11805414207205374, 'fraction_numerical': 0.047425198453083656, 'mean_word_length': 4.787985865724382, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, 'https://': 3, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '597437', 'license': 'MIT', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1600, 'n_words': 647, 'path': 'exercise-2/exercise.ipynb', 'repo_name': 'yeshuqi/ch7-iteration', 'size': '4913'}