<jupyter_start><jupyter_text>Challenge 2: SetsThere are a lot to learn about Python Sets and the information presented in the lesson is limited due to its length. To learn Python Sets in depth you are strongly encouraged to review the W3Schools tutorial on [Python Sets Examples and Methods](https://www.w3schools.com/python/python_sets.asp) before you work on this lab. Some difficult questions in this lab have their solutions in the W3Schools tutorial. First, import the Python `random` library.<jupyter_code>import random<jupyter_output><empty_output><jupyter_text>In the cell below, create a list named `sample_list_1` with 80 random values. Requirements:* Each value is an integer falling between 0 and 100.* Each value in the list is unique.Print `sample_list_1` to review its values*Hint: use `random.sample` ([reference](https://docs.python.org/3/library/random.htmlrandom.sample)).*<jupyter_code># Your code here

import random

sample_list_1 = random.sample(range(1, 100), 80)

print(sample_list_1)

len(sample_list_1)<jupyter_output>[70, 62, 20, 79, 80, 7, 76, 72, 6, 91, 42, 51, 24, 43, 45, 8, 88, 59, 1, 69, 66, 81, 13, 23, 52, 92, 37, 87, 5, 40, 99, 26, 83, 73, 3, 16, 82, 48, 65, 28, 67, 30, 12, 41, 47, 17, 21, 96, 27, 93, 19, 68, 84, 61, 4, 25, 29, 44, 22, 94, 34, 50, 9, 55, 54, 75, 57, 14, 32, 64, 15, 49, 77, 18, 90, 97, 89, 33, 10, 63]<jupyter_text>Convert `sample_list_1` to a set called `set1`. Print the length of the set. Is its length still 80?<jupyter_code># Your code here

set1 = set(sample_list_1)

print(set1)

len(set1)<jupyter_output>{1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 23, 25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 40, 41, 43, 44, 46, 47, 48, 49, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99}<jupyter_text>Create another list named `sample_list_2` with 80 random values.Requirements:* Each value is an integer falling between 0 and 100.* The values in the list don't have to be unique.*Hint: Use a FOR loop.*<jupyter_code># Your code here



sample_list_2  = [] 
for i in range(80):
    sample_list_2.append(random.sample(range(1, 100), 1)[0])
print(sample_list_2)

#why aren't there 80 values??

len(sample_list_2)
    
    




random.sample(range(1, 100), 1)[0]<jupyter_output><empty_output><jupyter_text>Convert `sample_list_2` to a set called `set2`. Print the length of the set. Is its length still 80?<jupyter_code># Your code here

import random

sample_list_2  = [] 
for i in range(80):
    sample_list_2.append(random.sample(range(1, 100), 1)[0])
print(sample_list_2)

set2 = set(sample_list_2)

print(set2)

len(set2)<jupyter_output>[60, 80, 63, 91, 47, 71, 39, 94, 25, 73, 40, 73, 48, 96, 88, 94, 56, 23, 33, 24, 20, 3, 11, 31, 82, 72, 92, 96, 63, 12, 37, 2, 24, 68, 94, 1, 94, 34, 8, 45, 57, 39, 72, 48, 7, 44, 24, 80, 97, 17, 44, 8, 61, 84, 85, 23, 21, 13, 35, 41, 20, 25, 63, 19, 39, 92, 63, 41, 96, 31, 32, 5, 31, 64, 75, 94, 49, 61, 97, 30]
{1, 2, 3, 5, 7, 8, 11, 12, 13, 17, 19, 20, 21, 23, 24, 25, 30, 31, 32, 33, 34, 35, 37, 39, 40, 41, 44, 45, 47, 48, 49, 56, 57, 60, 61, 63, 64, 68, 71, 72, 73, 75, 80, 82, 84, 85, 88, 91, 92, 94, 96, 97}<jupyter_text>Identify the elements present in `set1` but not in `set2`. Assign the elements to a new set named `set3`.<jupyter_code># Your code here

import random

sample_list_1 = random.sample(range(1, 100), 80)

print(sample_list_1)

len(sample_list_1)

set1 = set(sample_list_1)

#print(set1)

sample_list_2  = [] 
for i in range(80):
    sample_list_2.append(random.sample(range(1, 100), 1)[0])
print(sample_list_2)

set2 = set(sample_list_2)

#print(set2)

len(set2)

set3 = set1 - set2

print(set3)

len(set3)
#### Identify the elements present in `set2` but not in `set1`. Assign the elements to a new set named `set4`.
# Your code here

set4 = set2 - set1

print(set4)

len(set4)<jupyter_output>{37, 39, 59, 74, 45, 92, 17, 82, 53, 27, 60}<jupyter_text>Now Identify the elements shared between `set1` and `set2`. Assign the elements to a new set named `set5`.<jupyter_code># Your code here

#set5 = set1.intersection(set2)

#or

set5 = set1 & set2 

print(set5)<jupyter_output>{3, 5, 7, 12, 13, 17, 19, 20, 21, 24, 25, 30, 31, 33, 34, 35, 44, 47, 48, 49, 56, 57, 60, 61, 63, 64, 68, 72, 75, 80, 82, 84, 85, 91, 92, 94, 96, 97}<jupyter_text>What is the relationship among the following values:* len(set1)* len(set2)* len(set3)* len(set4)* len(set5)Use a math formular to represent that relationship. Test your formular with Python code.<jupyter_code># Your code here

80,52,35,11,45

len(set1) is always 80 (set1 outside of set2)

len(set2)  is always less than 80 (values are in set 1)

len(set3) is in set 1 only (and not set2)

set3 = set1 - set2

len(set4) is in set 2 only (but not set1)

set5 is in both set1 and set2<jupyter_output><empty_output><jupyter_text>Create an empty set called `set6`.<jupyter_code># Your code here

set6 = set()<jupyter_output><empty_output><jupyter_text>Add `set3` and `set5` to `set6` using the Python Set `update` method.<jupyter_code># Your code here

import random

sample_list_1 = random.sample(range(1, 100), 80)

#print(sample_list_1)

set1 = set(sample_list_1)

#print(set1)

sample_list_2  = [] 
for i in range(80):
    sample_list_2.append(random.sample(range(1, 100), 1)[0])
print(sample_list_2)

set2 = set(sample_list_2)

#print(set2)

#len(set2)

set3 = set1 - set2

#print(set3)

len(set3)

set6 = set()

set3 = set1 - set2

set5 = set1 & set2 

#print(set5)

set6.update(set3, set5)<jupyter_output>[67, 98, 25, 19, 95, 14, 83, 84, 97, 9, 69, 82, 98, 70, 21, 47, 4, 45, 83, 30, 53, 43, 21, 36, 25, 72, 45, 99, 12, 23, 13, 95, 68, 66, 20, 65, 41, 24, 25, 69, 18, 73, 60, 59, 28, 32, 45, 30, 17, 4, 92, 39, 76, 98, 79, 87, 59, 10, 31, 16, 76, 66, 43, 75, 9, 88, 32, 71, 96, 30, 7, 32, 44, 88, 75, 56, 41, 16, 4, 54]<jupyter_text>Check if `set1` and `set6` are equal.<jupyter_code># Your code here

if set1 == set6:
    print("TRUE")<jupyter_output>TRUE<jupyter_text>Check if `set1` contains `set2` using the Python Set `issubset` method. Then check if `set1` contains `set3`.*<jupyter_code># Your code here<jupyter_output><empty_output><jupyter_text>Using the Python Set `union` method, aggregate `set3`, `set4`, and `set5`. Then aggregate `set1` and `set2`.  Check if the aggregated values are equal.<jupyter_code># Your code here<jupyter_output><empty_output><jupyter_text>Using the `pop` method, remove the first element from `set1`.<jupyter_code># Your code here<jupyter_output><empty_output><jupyter_text>Remove every element in the following list from `set1` if they are present in the set. Print the remaining elements.```list_to_remove = [1, 9, 11, 19, 21, 29, 31, 39, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99]```<jupyter_code># Your code here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.146836912362159, 'fraction_numerical': 0.15510737086477075, 'mean_word_length': 4.6546349466776045, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 54, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 107, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '363945', 'license': 'MIT', 'n_tokens_mistral': 3690, 'n_tokens_neox': 2755, 'n_words': 1001, 'path': 'module-1/Dicts-Sets-Tuples/your-code/challenge-2.ipynb', 'repo_name': 'katherineling/daft-miami-1019-labs', 'size': '6892'}