<jupyter_start><jupyter_text>RWET Programming Exercise B: Lists and list operationsTo do this exercise, download this notebook and open it on your own computer. There are several tasks described below. Your job is to change the code in the cells so that the output from running the cell matches the expected output indicated above the cell.  Task 1: Simple indexing and list functionsThere is a list of numbers assigned to a variable `number_list` in the code below that has been assigned a list of numbers. Run this cell before filling in the answers below.<jupyter_code>number_list = [-2, -58, 4, 36, -6, 60, -57]<jupyter_output><empty_output><jupyter_text>Write another expression in the cell below, using square bracket index notation, that causes the 4th element of `number_list` (i.e., the number `36`) to be displayed when running the code in the cell.Expected output: `36` Now write an expression that evaluates to the number of items in the list (i.e., `7`), using the `len()` function.Expected output: `7` The following expression:    print max(number_list)    ... will print the largest value in `number_list` (i.e., `60`). Change the variable `x` in the code below so that the expression    print sorted(number_list)[x]    ... does the same thing. (i.e., when you run the cell, it should display `60`.)Expected output: `20`<jupyter_code>x = 0
sorted(number_list)[x]<jupyter_output><empty_output><jupyter_text>Task 2: List slicesWrite an expression below that evaluates to a slice of `number_list` starting with its second element and ending with its fifth element (exclusive).Expected output: `[-2, -58, 4, 36, -6, 60, -57]` Now, write an expression below that evaluates to a slice of `number_list` starting with its third element and ending at the end of the list.Expected output: `[4, 36, -6, 60, -57]` Finally, fill in a value for the variable `x` below so that the expression below it evaluates to a slice of `number_list` starting at the second-to-last element of the list and ending at the end of the list. (Hint: `x` should be a negative integer.)Expected output: `[60, -57]`<jupyter_code>x = 0
number_list[x:]<jupyter_output><empty_output><jupyter_text>Task 3: List comprehensionsFor this problem set, I'm introducing a new Python operator: the modulo operator, `%`. This operator returns the *remainder* of dividing one integer by another. For example:<jupyter_code>22 % 3<jupyter_output><empty_output><jupyter_text>This expression evaluates to `1` because the remainder of dividing `22` by `3` is `1`. We can use the modulo operator to test whether or not a number is even (i.e., divisible by 2), by using the number `2` on the right side of the operator:<jupyter_code>100 % 2
101 % 2<jupyter_output><empty_output><jupyter_text>Given the above information, write a list comprehension that evaluates to a list containing *only* the members of `number_list` that are *divisible by three*. Use the modulo operator in the membership expression of the list comprehension.Expected output: `[36, -6, 60, -57]`  Task 4: Splitting stringsIn the cell below, a variable `float_str` is set to a string containing a list of floating-point numbers, separated by semicolons (`;`). (Make sure to run this cell before you proceed, so that the variable will be available in subsequent cells.)<jupyter_code>float_str = "5.8;6.9;3.1;5.9;6.6;6.5;6.5;5.6;6;6.4;3.32;6.0;6.0;6.3;6.6;6.6"<jupyter_output><empty_output><jupyter_text>Write an expression below that converts this string into a list of floating-point numbers. The type of the expression should be `list` and the type of individual elements in the list should be `float`. Hint: You'll need to use the `float()` function, the `.split()` method, and a list comprehension.Expected output:    [5.8, 6.9, 3.1, 5.9, 6.6, 6.5, 6.5, 5.6, 6.0, 6.4, 3.32, 6.0, 6.0, 6.3, 6.6, 6.6] Using the expression you wrote above as a starting point, write an expression below that evaluates to the *sum* of the numbers in the list.Expected output: `94.11999999999999` (or close to that)  Task 5: Strings in list comprehensionsIn the cell below, I've defined a list of strings and assigned it to a variable called `greek`. Make sure to run this cell before you continue.<jupyter_code>greek = ["alpha", "beta", "gamma", "delta", "epsilon"]<jupyter_output><empty_output><jupyter_text>Okay. Your job in the next cell is to write an expression that evaluates to a list of strings in `greek` that contain *exactly five letters*.Expected output: `["alpha", "gamma", "delta"]` In the cell below, write an expression that evaluates to a string containing each of the *first letters* of each string in `greek`. Hint: You'll need to use a list comprehension and the `.join()` method.Expected output: `'abgde'`  Task 6: For loopsThe cell below has the skeleton of the `for` loop written for you. Replace the string `"blip"` with an expression such that the cell, when executed, outputs the first ten multiples of five.Expected output:    0    5    10    15    20    25    30    35    40    45<jupyter_code>for i in range(10):
    print("blip")<jupyter_output>blip
blip
blip
blip
blip
blip
blip
blip
blip
blip
{'fraction_non_alphanumeric': 0.09152872444011685, 'fraction_numerical': 0.03524829600778968, 'mean_word_length': 4.71301446051168, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '491041', 'license': 'BSD-Source-Code', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1499, 'n_words': 734, 'path': 'programming-exercise-b.ipynb', 'repo_name': 'sjoerdapp/colab', 'size': '5135'}