a = [1,2,3,4,5]
b = ['a','b','c','d','e']
for x,y in zip (a,b):
print (x, y)
--------------------
1 a
2 b
3 c
4 d
5 e
----------------------------------------
----------------------------------------
----------------------------------------
import
numpy as np
def
func(x):
return x * 2
b
= map(func, [1, 2, 3, 4])
for
x in b:
print(x)
--------------------
2
4
6
8
* map 오브젝트는 리스트 같지만 원소에 직접 접근은 불가
* b[0] 사용 불가
----------------------------------------
a
= lambda x, y: x * y
print(a(3,
4))
--------------------
12
----------------------------------------
import
numpy as np
k
=[
[11,12,13,14,15,16],
[21,22,23,24,25,26],
[31,32,33,34,35,36],
[41,42,43,44,45,46],
[51,52,53,54,55,56]
]
a
= np.array(k)
print(a[::2,1:3:)])
--------------------
[[12
13]
[32 33]
[52 53]]
* a[start : end : step] // row에 적용
* a[start : end : step, start, end] // row, column에 적용
댓글 없음:
댓글 쓰기