<jupyter_start><jupyter_text>Basic Python for numerical science **List vs Tuple vs Dict**|-----------|------|-------|------||| List | Tuple | Dict ||-----------|------|-------|------||Read|index|index|key||Mutable|yes|no|yes|<jupyter_code># Try change List
try:
  a = [0,1,2,3] # List
  a[0] = 1
  print("List changed to",a)
except:
  print("Can't change List")

# Try change Tuple
try:
  b = (0,1,2,3) # Tuple
  b[0] = 1
  print("Tuple changed to",b)
except:
  print("Can't change Tuple")

# Try change Dict by index
try:
  c= {'a':'0','b':'1','c':'2','d':'3'}
  cc = c.copy()
  cc[0] = 1
  print("Dict changed from",c,"to",cc)
except:
  print("Can't change Dict by index")

# Try change Dict by key
try:
  c = {'a':'0','b':'1','c':'2','d':'3'}
  cc = c.copy()
  cc['a'] = 1
  print("Dict changed from",c,"to",cc)
except:
  print("Can't change Dict by key")<jupyter_output>List changed to [1, 1, 2, 3]
Can't change Tuple
Dict changed from {'a': '0', 'b': '1', 'c': '2', 'd': '3'} to {'a': '0', 'b': '1', 'c': '2', 'd': '3', 0: 1}
Dict changed from {'a': '0', 'b': '1', 'c': '2', 'd': '3'} to {'a': 1, 'b': '1', 'c': '2', 'd': '3'}<jupyter_text>At this point use will noticed that we need to use`Dict.copy()` while `List` and `Tuple` don'tLet's check it out why???<jupyter_code>after = before = {'a':'original'}
after['a'] = 'changed'

print(after,before)
assert after!=before, "They're same!!!?????"
before = {'a':'original'}
after = before.copy()
after['a'] = 'changed'

print(after,before)
assert after!=before, "They are same!!"<jupyter_output>{'a': 'changed'} {'a': 'original'}<jupyter_text>Lambda : The magic anonymously defined function ???We don't have to use `def` to define function everytime. :)<jupyter_code>increase1  = lambda x: x+1<jupyter_output><empty_output><jupyter_text>This will create a function named `incease1` which take 1 parameters `x` then return `x+1`<jupyter_code>increase1(3)
sum_then_minus = lambda x,y,z: x+y-z
sum_then_minus(3,2,1) # 3+2-1
split_then_join_with_period = lambda text: ".".join(text.split(" "))
split_then_join_with_period("Hello the amazing AI Builders")
import random
random_weight = lambda : random.random() # This lambda don't take parameters
random_weight()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23392857142857143, 'fraction_numerical': 0.025892857142857145, 'mean_word_length': 4.820779220779221, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '373170', 'license': 'MIT', 'n_tokens_mistral': 901, 'n_tokens_neox': 858, 'n_words': 241, 'path': '01_basic_python.ipynb', 'repo_name': 'PatrickChoDev/HowDidYouMakeIt', 'size': '2240'}