<jupyter_start><jupyter_text>Equality vs. Sameness<jupyter_code>a = [1,2,3]
b = a
a[0] = 99999
print("b =",b)
print("Equality:", a == b)
print("Sameness:", a is b)
print("id(a):", id(a))
print("id(b):", id(b))
a = [1,2,3]
b = [1,2,3]
print("Equality:", a == b)
print("Sameness:", a is b)
print("id(a):", id(a))
print("id(b):", id(b))
a[0] = 99999
print("b =",b)<jupyter_output>Equality: True
Sameness: False
id(a): 4363681352
id(b): 4362064456
b = [1, 2, 3]<jupyter_text>Mutability<jupyter_code>my_tuple = (1,2,3) # Tuples are not mutable
my_tuple[0] = 99999
my_string = "this is a string" # Neither are strings
my_string[0] = "!"
list1 = [1,2,3] # Be careful with +=
list2 = list1
list1 += [4]
print("list1 =",list2)
print("list2 =",list2)
tuple1 = (1,2,3) # Be careful with +=
tuple2 = tuple1
tuple1 += (4,)
print("tuple1 =",tuple1)
print("tuple2 =",tuple2)<jupyter_output>tuple1 = (1, 2, 3, 4)
tuple2 = (1, 2, 3)
{'fraction_non_alphanumeric': 0.23060109289617486, 'fraction_numerical': 0.09508196721311475, 'mean_word_length': 6.046153846153846, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '425491', 'license': 'MIT', 'n_tokens_mistral': 464, 'n_tokens_neox': 423, 'n_words': 101, 'path': 'demos/lecture01/lecture01.ipynb', 'repo_name': 'royadams/intro_to_numerical_computing_with_python', 'size': '915'}