๋ฐ์ํ
Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- ํฉํ ๋ฆฌ์ผ ์ง๋ฒ
- ์๋ฐ
- jdbc
- ์ง ๊ฐ ์์ธก ๋ถ์
- Do_it
- Extended Slices
- ์ต์
- mysql
- 2BPerfect
- matplotlib
- ๋ธ๋ผ์ฐ์ ์คํ
- ์ด์ง์ ๋ณํ
- sql
- MacOS
- Do it
- ์ ํ ํฌ ํ์ด์ฌ
- ์ฐธ์กฐ ๋ณ์
- dacon
- ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ
- ํ๋ก๊ทธ๋๋จธ์ค
- ์์ด
- ๋ฐฑ์ค
- DFS
- BFS
- PYTHON
- java
- ํ์ ๋ณ์
- ์ด๊ฒ์ด ์ทจ์ ์ ์ํ ์ฝ๋ฉํ ์คํธ๋ค
- np.zeros_like
- ๋ฐ์ค๊ทธ๋ํ
Archives
- Today
- Total
๐ฆ ๊ณต๋ฃก์ด ๋์!
python_re_study...5 ๋ณธ๋ฌธ
abs(x) #์ ๋ ๊ฐ์ ๋๋ ค์ฃผ๋ ํจ์
all(x) # for๋ฌธ์ผ๋ก ๊ทธ ๊ฐ์ ์ถ๋ ฅํ ์ ์์ ๋(๋ฐ๋ณต ๊ฐ๋ฅํ ๊ฐ) true ๊ฐ์ ์ถ๋ ฅ
# ๊ทธ ์์ ์ค 0์ด ์์ผ๋ฉด false ๋น ๊ฐ์ผ ๊ฒฝ์ฐ true
# ๋ฆฌ์คํธ, ํํ, ๋ฌธ์์ด, ๋์
๋๋ฆฌ, ์งํฉ
any(x) # ๋ฐ๋ณต ๊ฐ๋ฅ ๊ฐ์ ์
๋ ฅ ์ธ์๋ก ๋ฐ์ ์์ ์ค
# true๊ฐ์ด ์์ ๋ true
# ๋น ๊ฐ, "",0 false
chr(x) # ์ ๋์ฝ๋ ๊ฐ์ ์
๋ ฅ๋ฐ์ ๊ทธ ์ฝ๋์ ํด๋นํ๋ ๋ฌธ์๋ฅผ ์ถ๋ ฅํ๋ค.
dir(x) # ๊ฐ์ฒด๊ฐ ์์ฒด์ ์ผ๋ก ๊ฐ์ง๊ณ ์๋ ๋ณ์๋ ํจ์๋ฅผ ๋ณด์ฌ์ค๋ค
ex)
>>> dir([1, 2, 3])
['append', 'count', 'extend', 'index', 'insert', 'pop',...]
>>> dir({'1':'a'})
['clear', 'copy', 'get', 'has_key', 'items', 'keys',...]
divmod(x,y) # x๋ฅผ y๋ก ๋๋ ๋ชซ๊ณผ ๋๋จธ์ง๋ฅผ ํํ ํํ๋ก ๋๋ ค์ฃผ๋ ํจ์
// # ๋ชซ์ ๊ตฌํ๋ ์ฐ์ฐ์
% # ๋๋จธ์ง๋ฅผ ๊ตฌํ๋ ์ฐ์ฐ์
enumerate # ์์๊ฐ ์๋ ์๋ฃํ์ ๋ฐ์์ ์ธ๋ฑ์ค ๊ฐ์ ํฌํจํ๋ enumerate ๊ฐ์ฒด๋ก ๋๋ ค์ค๋ค.
# ์ฃผ๋ก for๋ฌธ๊ณผ ๊ฐ์ด ์ฐ์ธ๋ค.
ex)
>>> for i, name in enumerate(['body', 'foo', 'bar']):
... print(i, name)
...
0 body
1 foo
2 bar
eval(expression) # ์คํ ๊ฐ๋ฅํ ๋ฌธ์์ด์ ์
๋ ฅ ๋ฐ์ ๋ฌธ์์ด์ ์คํํ ๊ฒฐ๊ด๊ฐ์ผ๋ก ๋๋ ค์ฃผ๋ ํจ์.
ex)
>>> eval('1+2')
3
>>> eval("'hi' + 'a'")
'hia'
>>> eval('divmod(4, 3)')
(1, 1)
filter(x,y) # ์ฒซ ๋ฒ์งธ ์ธ์๋ก ํจ์ ์ด๋ฆ์, ๋ ๋ฒ์งธ ์ธ์๋ก ๊ทธ ํจ์์ ์ฐจ๋ก๋ก ๋ค์ด๊ฐ ๋ฐ๋ณต ๊ฐ๋ฅํ ์์๋ฅผ
# ๋ฐ๊ณ ์ฒซ ๋ฒ์งธ ์ธ์์ธ ํจ์์ ์
๋ ฅ๋์์ ๋ ๋ฐํ ๊ฐ์ด ์ฐธ์ธ ๊ฒ๋ง ๋ฌถ์ด์ ๋๋ ค์ค๋ค.
===
def positive(l):
result=[]
for i in l:
if i>0:
result.append(i)
return result
==
def positive(l):
result=[i for i in l if i>0]
return result
print(positive([1,-3,2,0,-5,6]))
===
def positive(x):
return x>0
print(list(filter(positive,[1,-3,2,0,-5,6]))
===
list(filter(lambda x: x > 0, [1, -3, 2, 0, -5, 6]))
map(x) # ์ ์ฒด์ ์ผ๋ก filter์ ๋์ผํ๋ filter์ ์กฐ๊ฑด๋ฌธ์ ์ฐธ์ ๊ฐ์ ์ฃผ๋ ๋ฐ๋ฉด
# map์ ํจ์๋ฅผ ์ ์ฉํ๋ค.
def two_times(x):
rs=[]
for y in x:
rs.append(y*2)
return rs
==
def two_times(x):
rs=[y*2 for y in x]
return rs
==
list(lamda x:x*2)
def two_times(numberList):
result = [ ]
for number in numberList:
result.append(number*2)
return result
result = two_times([1, 2, 3, 4])
print(result)
===
def two_times(x):
return x*2
list(map(two_times, [1, 2, 3, 4]))
===
list(map(lambda a: a*2, [1, 2, 3, 4]))
์ฐธ๊ณ :https://wikidocs.net/book/1
์ ํ ํฌ ํ์ด์ฌ
** ์ ํ ํฌ ํ์ด์ฌ ์คํ๋ผ์ธ ์ฑ (๊ฐ์ ํ) ์ถ๊ฐ !! (2019.06) ** * [์ฑ ๊ตฌ์ ์๋ด](https://wikidocs.net/4321) ์ด ์ฑ ์ ํ์ด์ฌ ...
wikidocs.net
๋ฐ์ํ
'Development > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
python_re_study...7 (0) | 2021.12.21 |
---|---|
python_re_study...6 (0) | 2021.12.19 |
python_re_study...4 (0) | 2021.12.18 |
python_re_study...3 (0) | 2021.12.17 |
python_re_study...2 (0) | 2021.12.15 |
Comments