<jupyter_start><jupyter_text>Quiz 1 Practice ExercisesThese questions relate to the [learning objectives](https://canvas.eee.uci.edu/courses/42645/pages/learning-objectives?module_item_id=1612181) for the Quiz 1 (which is scheduled for Thursday of Week 2).For each of these topics, we state the learning objective and then give one or more practice exercises.  Documentation* Extract basic information from Python documentation (such as the result of using help).  Exercise: Use NumPy's `arange` (look it up using `help`) function to create the NumPy array```array([3. , 3.5, 4. , 4.5, 5. , 5.5, 6. , 6.5, 7. , 7.5])```What goes wrong if you try to make the list version using Python's built-in `range` function?  Errors* Extract basic information from a Python error message.  Exercise:There is a function called `zeros` built into NumPy.  The documentation for this function shows the following:```Help on built-in function zeros in module numpy:zeros(...)    zeros(shape, dtype=float, order='C')        Return a new array of given shape and type, filled with zeros.        Parameters    ----------    shape : int or tuple of ints        Shape of the new array, e.g., ``(2, 3)`` or ``2``.    dtype : data-type, optional        The desired data-type for the array, e.g., `numpy.int8`.  Default is        `numpy.float64`.    order : {'C', 'F'}, optional, default: 'C'        Whether to store multi-dimensional data in row-major        (C-style) or column-major (Fortran-style) order in        memory.``` If we evaluate `np.zeros(3,5)`, we get the following error:```---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last) in ----> 1 np.zeros(3,5)TypeError: Cannot interpret '5' as a data type``` * The user was trying to make a 3-by-5 array of zeros.  Do you see what the user did wrong?* How should the code be corrected?  Data types* Choose from among list, tuple, range, set, NumPy array, depending on which is an appropriate data type for a particular task.  Exercise:For each pair of data types, give an advantage/disadvantage between them.  Convert* Convert between different data-types using syntax like `np.array(my_tuple)`.  Exercise:What is the difference between the following?  Give a specific example, and explain how the results are different. `str(list(x))` vs `list(str(x))`.  Is it possible for these two to produce the same output?  Replace for loops* Replace code written with a for-loop with code using list comprehension.  Exercise:Rewrite the following using list comprehension.  (What is an example of a value of `my_list` for which this code makes sense?)<jupyter_code>new_list = []
for x in my_list:
    if len(x) > 2:
        new_list.append(x)<jupyter_output><empty_output><jupyter_text>Do the same thing for the following.<jupyter_code>new_list = []
for x in my_list:
    if len(x) > 2:
        new_list.append(x)
    else:
        new_list.append(0)<jupyter_output><empty_output><jupyter_text>Do the same for the following.  Use `my_list[:5]` to refer to the first 5 elements in `my_list`.<jupyter_code>new_list = []
for i in range(5):
    new_list.append(my_list[i]**2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1228287841191067, 'fraction_numerical': 0.015818858560794045, 'mean_word_length': 3.393732970027248, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '542646', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 969, 'n_tokens_neox': 916, 'n_words': 396, 'path': '_build/html/_sources/Week2/Quiz1-Practice.ipynb', 'repo_name': 'ChristopherDavisUCI/UCI-Math-10-W22', 'size': '3224'}