<jupyter_start><jupyter_text>1.函式 將流程 _抽象化、包裝_ def functionName(value): pass<jupyter_code>def sumOf(num):
    total = 0
    for i in range(num + 1): #0 ... value-1
        total = total + i
    
    return total
print("sumOf:",sumOf(100))

# 預設值
def sumOf2(num=100):
    total = 0
    for i in range(num + 1): #0 ... value-1
        total = total + i
    
    return total

print("sumOf2:",sumOf2())


# 函式還沒寫要在裡面加 pass
def passFunction():
    pass

passFunction()

# 如果完全空白就會出錯
def blankFunction():<jupyter_output><empty_output><jupyter_text>2.內建函式<jupyter_code>print("輸出")
print("絕對值:",abs(-5))
print("數字 轉 Unicode字:",chr(65),chr(12549))
print("Unicode字 轉 數字:",ord("A"),ord("ㄅ"))
print("10進制 轉 8進制:",oct(7))
print("10進制 轉 16進制:",hex(15))
a = [1,2.0,"th"]
print("轉成 tuple:",tuple(a))
print("轉成 list:",list(a))
print("轉成 int:",int(2.0))
print("轉成 float:",float(2))
print("轉成 complex:",complex(2))
print("取最大值:",max(1,2,3))
print("取最小值:",min(1,2,3))
b = 1
print("檢查變數類別: b=1:",isinstance(b, (int))," a=[1,2.0,\"th\"]",isinstance(a, (int,float)))<jupyter_output>輸出
絕對值: 5
數字 轉 Unicode字: A ㄅ
Unicode字 轉 數字: 65 12549
10進制 轉 8進制: 0o7
10進制 轉 16進制: 0xf
轉成 tuple: (1, 2.0, 'th')
轉成 list: [1, 2.0, 'th']
轉成 int: 2
轉成 float: 2.0
轉成 complex: (2+0j)
取最大值: 3
取最小值: 1
檢查變數類別: b=1: True  a=[1,2.0,"th"] False<jupyter_text>3.可變變數 \*list \*tuple **dict<jupyter_code>def sumOf(*args):
    total = 0
    for i in args:
        total = i + total
    return total

print(sumOf(1,2,3,4))

tu = (1,2,3,4)
li = [1,2,3,4]
print("*tu:",sumOf(*tu)) #拆解為 1 2 3 4
print("*li:",sumOf(*li))

def namePlace(**kwargs):
    for key in kwargs:
        print(key,"=",kwargs[key])

namePlace(City="Kaohsiung")

c = {"City":"Taipei"}
namePlace(**c) #以dict傳入<jupyter_output>10
*tu: 10
*li: 10
City = Kaohsiung
City = Taipei<jupyter_text>4.值和址[Understanding Python variables and Memory Management](http://foobarnbaz.com/2012/07/08/understanding-python-variables/)<jupyter_code>a = 1
print("a:", a, "| addr:",id(a))

b = 1
print("b:", b, "| addr:",id(b))

a = 256
print("a:", a, "| addr:",id(a))

b = 1
print("b:", b, "| addr:",id(b))

b = 256
print("b:", b, "| addr:",id(b))

a = 257
print("a:", a, "| addr:",id(a))

b = 257
print("b:", b, "| addr:",id(b))

c = "Meow"
print("c:", c, "| addr:",id(c))

d = "Meow"
print("d:", d, "| addr:",id(d))

c = "Meow Meow"
print("c:", c, "| addr:",id(c))

d = "Meow Meow"
print("d:", d, "| addr:",id(d))<jupyter_output>a: 1 | addr: 1540471248
b: 1 | addr: 1540471248
a: 256 | addr: 1540479408
b: 1 | addr: 1540471248
b: 256 | addr: 1540479408
a: 257 | addr: 1902195627248
b: 257 | addr: 1902195627216
c: Meow | addr: 1902195838848
d: Meow | addr: 1902195838848
c: Meow Meow | addr: 1902195742064
d: Meow Meow | addr: 1902195742128
{'fraction_non_alphanumeric': 0.22242579699523635, 'fraction_numerical': 0.10296812019054599, 'mean_word_length': 4.66390041493776, 'pattern_counts': {'":': 1, '<': 14, '<?xml version=': 0, '>': 14, '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': '256292', 'license': 'MIT', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1360, 'n_words': 284, 'path': 'Ep3/Ep3.ipynb', 'repo_name': 'ouvek-kostiva/stockchooser', 'size': '2729'}