< built-in function >
sum()
min(), max()
eval(string) -> 문자열로 된 수식을 계산
sorted( [dictionary] ) -> 키 기준 정
sorted( [dictionary], key=lambda a : x[ a ] ) -> 값 기준 정렬
< itertools >
from itertools import permutations 순열
list( permutations(a, b) )
from itertools import combinations 조합
list( combinations(a,b) )
from itertools import product 중복순열
from itertools import combinations_with_replacement 중복조합
< heapq >
heappush()
heappop()
< bisect >
bisect_left(array, data)
bisect_right(array, data)
< collections >
from collections import deque - 인덱싱 슬라이싱 x
맨 앞, 맨 끝 데이터 추가 및 삭제 가능
appendleft(data)
append
from collections import Counter
count(data) -> 숫자 결과 리턴
dic(c) -> data를 key로 카운트 결과를 값으로
< math >
factorial(data)
sqrt(data)
gcd(data)
< func >
def add(a, b) :
return a+b
add = lambda a,b : a+b
add(x,y)
< 수의 연산 >
반올림 round()
몫 //
나머지 %
거듭제곱 **
a = 1e9 -> 10^9
< String>
인덱스로 슬라이싱 가능 [a, b] -> a ~ b-1번 인덱스까지
< List >
c++ vector, javascript array
리스트 초기화시 [ ] 내부에 for문 if문 포함해서 작성 가능
append(data)
sort()
sort(reverse=True)
reverse()
insert(index, data)
count(data)
remove(data) -> 중복시 첫번째 값 제거
< Tuple >
수정 불가
( )
< Dictionary >
{ key : value }
keys()
values()
< Set >
{ 중복 x, 순서 x, 집합의 연산 }
합집합| 교집합& 차집합-
add(data)
update(list data) -> 리스트의 항목을 하나씩 추가함
remove(data)
< 루프 >
while ~ :
for _ in :
< 조건문 >
if ~ :
elif ~ :
else :
data in / not in list
< in/output>
global a -> 전역변수 선언
var = input()
import sys
sys.stdin.readline().rstrip()
l1 = list(map(int, input().split()))
print(a, b, sep=' / ') 구분자
print(a, b, end=' ')