超好用的2個Jupyter notebook 延伸工具
- Table of content : 針對Markdown cell 提供目錄
- autopep8: python代碼格式化工具
打開Anaconda Prompt , 執行
(3) 重新開啓Jupyter Notebook, Enable "Table of content "
超好用的2個Jupyter notebook 延伸工具
[[ 0 1 2 3 4 5 6] [ 7 8 9 10 11 12 13] [14 15 16 17 18 19 20] [21 22 23 24 25 26 27] [28 29 30 31 32 33 34]]
18
[[ 0 1 2 3 4 5 6] [ 7 8 9 10 11 12 13] [14 15 16 17 18 19 20]]
[[ 0 1 2 3] [ 7 8 9 10] [14 15 16 17]]
print(a[1:5:2,::3]) #row : 1,3 ; column: no start, so start(0):no end:step 3==> 0,3,6,....[[ 7 10 13] [21 24 27]]
[ 1 8 15 22 29]
[[ 1 3 4] [ 8 10 11] [15 17 18] [22 24 25] [29 31 32]]
[ 2 72 240 506 870]
870
找最小值print(np.min(y))
2
陣列元素值加總print(np.sum(y))
1690
陣列元素四捨五入
np.around([0.55, 0.65, 0.05], decimals=1)
array([0.6, 0.6, 0.0])

[[1 2 3 4] [1 2 3 4] [1 2 3 4]] [[5 5 5 5] [6 6 6 6] [7 7 7 7]]
ambda argument_list: expression
[1, 4, 9]
>>> x = int(input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: ... print('Zero') ... elif x == 1: ... print('Single') ... else: ... print('More') ...
>>> # Measure some strings: ... words = ['cat', 'window', 'defenestrate'] >>> for w in words: ... print(w, len(w)) ... cat 3 window 6 defenestrate 12
>>> for w in words[:]: # Loop over a slice copy of the entire list. ... if len(w) > 6: ... words.insert(0, w) ... >>> words ['defenestrate', 'cat', 'window', 'defenestrate']
>>> for i in range(5): ... print(i) ... 0 1 2 3 4
a = ['Mary', 'had', 'a', 'little', 'lamb'] for i in range(len(a)): print(i, a[i]) 0 Mary 1 had 2 a 3 little 5 lamb
a = ['Mary', 'had', 'a', 'little', 'lamb'] i=0while i < len(a):print(i, a[i])i+=10 Mary 1 had 2 a 3 little 4 lamb