<jupyter_start><jupyter_text>DataScience Course $\circ$ Python Programming $\circ$ Recap 2By Dr <NAME>     Topics- list comprehension- function, lambda expression- map, filter- class, method  Exercises- Run provided codes prior to the exercise question, e.g. ``pi = math.pi``- Add a **new cell** to try your code- Type in Python code in the box to get the results as displayed right below__Warning__: results will be replaced, so make sure you add a new cell to try your code<jupyter_code>import math

ls_data = [2, 3, 5, 7, 11, 13, 17]
ls_age = [3, 6, 12, 18, 25, 30, 60]
quote = '''"The development of full artificial intelligence could spell the end of the human race….It would take off on its own, and re-design itself at an ever increasing rate. Humans, who are limited by slow biological evolution, couldn't compete, and would be superseded." -- <NAME> told the BBC'''

dict_data = {
    'path'  : "./data/",
    'file'  : "Purchases",
    'ext'   : ".csv",
    'sep'   : "|",
}

def func(x):
    return math.pi*2*x

def is_minor(x):
    return (x < 18)<jupyter_output><empty_output><jupyter_text>**$\Rightarrow$ Use list comprehension to generate $x^2$ for each value $x$ in `ls_data`** **$\Rightarrow$ Use list comprehension to select values in `ls_data` that are less than `10`** **$\Rightarrow$Map the function `func()` to all elements in the list `[2, 3, 4]`, and see the results** **$\Rightarrow$Define a new function called `func2` that does some calculation (e.g. $x^2$).Then, map `func2` to all elements in the list `[2, 3, 4]` and see the results** **$\Rightarrow$Filter the ages in the list `ls_age` to obtain only the minors (Use the function `is_minor()`)** **$\Rightarrow$Filter the ages in the list `ls_age` to obtain only the minors (Use `lambda`)** **$\Rightarrow$Use string methods to split the message and the source from the string `quote`** ** OPTIONAL $\Rightarrow$Use string methods e.g. `lower()`, `find()` together with a `for`-loop to count the number of occurences of the word "human"**<jupyter_code># find the position of the first occurence<jupyter_output>... nd of the human race….it  ...
... ing rate. humans, who are ...
{'fraction_non_alphanumeric': 0.12974976830398516, 'fraction_numerical': 0.017608897126969416, 'mean_word_length': 4.227602905569007, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '341300', 'license': 'MIT', 'n_tokens_mistral': 705, 'n_tokens_neox': 650, 'n_words': 304, 'path': 'pynotes/e02_Python_Recap_2.ipynb', 'repo_name': 'meng234/ds_python_1', 'size': '2187'}