<jupyter_start><jupyter_text>LAB --- ** Exercise**With an influx of people registering for the Community BBQ, we want to make sure the email addresses they enter into the registration form is valid. We will use regexes to do this.Let's break down the regex string you will be creating in a bit that will contain a pattern for valid email address. We will use the email address, `<EMAIL>`, as an example. We want our pattern to:1. match every character from the beginning of the string up until the `@` character. For example, our pattern should match `example@` from our email address.2. match ever character *except* ".". For example, our pattern should match `gmail` from our email address.3. match the domain characters (with a min length of 2 and a max length of 10 characters) until the end of the string. For example, our pattern should match `.com` from our email address.Your pattern will combine the attributes above sequentially as one regex pattern.HINTs: if you are having trouble, here are some helpful hints that map to the above attributes of your pattern:1. this pattern will use the `^`, `.`, `+`, and `@` characters2. this pattern will use the `[`, `^`, `.`, `]`, `.`, and `*` characters3. this pattern will use the `\`, `.`, `[a-z]`, `{2,10}`, and `$` charactersThen, create a function, `check_email_address()`, that:- takes required argument `email` that is a string of an email address- compiles your one regex pattern using `flags=re.IGNORECASE` as an argument to ignore case- if the pattern matches the email address, print a message saying that it's valid; otherwise, print a message saying it's not valid<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>** Exercise**Now you have enough information to start working on a countdown clock for this year's Community BBQ since the 2020 event was cancelled for COVID reasons.The next BBQ in 2021 will start on July 17, 2021 in Providence, RI at 10am.Do the following:- create a `datetime` instance from the `datetime` module with the above times and dates named `bbq_date`- create a `datetime` instance from the `datetime` module of the time and date of now named `now`- compute the difference between `now` and `bbq_date` named `countdown`- print `"Countdown to Community BBQ 2021:"` followed by `countdown`Taking the difference between two `datetime` instances returns a `datetime.timedelta` instance, which is your `countdown` variable!<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>Now that you know how to add time zone information to a Python `datetime` instance, you can improve your Community BBQ countdown code. Here in Providence, RI the time zone is `"America/New_York"`.Do the following:- create `bbq_date` as above but with passing the correct time zone to the `tzinfo` argument.- create `now` as above but with the correct time zone- compute the difference between `now` and `bbq_date` named `countdown`- print `"Countdown to Community BBQ 2021:"` followed by `countdown` and the name of the time zone<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>With the subtraction operator, your `timedelta` object couldn’t count intervals of time larger than a day. However, `relativedelta` allows you to show the years, months, and days remaining.Do the following:- replace the plain substraction operator with `relativedelta` and save the output to `countdown`- print `"Countdown to Community BBQ 2021:"` followed by `countdown` and the name of the time zone<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>This output tells us each individual time unit of when the Community BBQ will happen but it isn't very pretty. Let's fix that.Recall, the built-in function```pythongetattr(obj, name)```returns the value of the named attribute of `obj` where `name` is a string. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. First, we will create a function, `time_amount()`, that:- takes required arguments:    - `time_unit`: time unit string    - `countdown`: `relativedelta` instance- gets the value from `countdown` from named attribute `time_unit`- returns the time attribute value with the `time_unit` as one stringThe time units we care about are years, months, days, hours, minutes, and seconds.Then, do the following:- for each time unit, use `time_amount()` to create a list of time value and time unit strings- print `"Countdown to Community BBQ 2021:"` followed by joining each time value and the name of the time zone<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>In lecture, you learned about creating `datetime` instances using `.strptime()`. This method uses a special mini-language within Python to specify how the date string is formatted.Python datetime has an additional method called ```python.strftime(format_str)```that allows you to format a datetime instance to a string. In a sense, it’s the reverse operation of parsing using `.strptime()`. You can differentiate between the two methods by remembering that the `p` in `.strptime()` stands for **parse**, and the `f` in `.strftime()` stands for **format**.In your Community BBQ countdown, you can use `.strftime()` to print output to let the user know the date on which the Community BBQ will start. You can find the formatting codes that you want to use [here](https://strftime.org/).Here is the desired date format for the Community BBQ: `Saturday, July 17, 2021 at 10:00 AM EDT`Do the following:- use `.strftime` to retrieve the desired date format above- print `"Community BBQ 2021 will start on:"` then the retrieved date format retrieved- print `"Countdown to Community BBQ 2021:"` followed by joining each time value<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>** Exercise**Now that we have a countdown timer till the next Community BBQ, we can share it with everyone to get people extra excited for the gathering! To do this, we will pickle a few objects we've created and store our objects at `day_4_assets/lab`.First, create `bbq_pickle_dict` that is a dictionary of string variable names as keys with picklable objects as values. Insert the following into `bbq_pickle_dict`:- the Community BBQ start date variable you created- the output of each time value of the countdownThen, create a function, `serialize_objs()` that:- takes required arguments:    - `pickle_dict`: dictionary of string variable names as keys with picklable objects as values    - `path`: where to store the pickled objects- pickles each item in `pickle_dict`- prints a message to the user that the file was pickled along with the path to the pickled objectTest `serialize_objs()` by passing in `bbq_pickle_dict` and the correct storage location.<jupyter_code># TODO: insert solution here<jupyter_output><empty_output><jupyter_text>To verify that we pickled our objects successfully, we will unpickle what you just pickled and output them to the console.Create a function, `deserialize_objs()`, that:- takes required arugment `unpickle_lst` that is a list of paths to unpickle- returns a dictionary of string variable names as keys with picklable objects as valuesTest `deserialize_objs()` by passing in a list of pickled paths, print out the results, and verify that your unpickled objects are the same as your previously pickled objects.<jupyter_code># TODO: insert solution here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07657356675130296, 'fraction_numerical': 0.00841908325537886, 'mean_word_length': 5.283795130142737, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 1, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '308998', 'license': 'MIT', 'n_tokens_mistral': 2039, 'n_tokens_neox': 1936, 'n_words': 1056, 'path': 'week_3/day_4_lab.ipynb', 'repo_name': 'brown-ccv/workshop_python_2021', 'size': '7493'}