1. 반복문
1.1. while문
1.2. for문
1.2.1. range(시작값, 끝값+1)
2. 함수
2.1. global
2.2. lambda(입력으로 받는 매개변수 : 반환값)
3. 입출력
3.1. 입력
3.1.1. input( )
3.1.2. map( )
3.1.2.1. map( function, iterable(적용 대상))
3.1.2.2. 공백 구분 데이터
3.1.2.2.1. list(map(int, input.split( )))
3.1.2.3. 공백 구분 데이터 개수 적을 때
3.1.2.3.1. a,b,c = map(int, input( ).split( ))
3.1.3. sys.stdin.readline( )
3.1.3.1. 문자열 입력
3.1.3.1.1. sys.stdin.readline( ).rstrip( )
3.1.3.2. 한 개의 정수 입력
3.1.3.2.1. int(sys.stdin.readline( ))
3.1.3.3. 정해진 개수의 정수 한 줄에 입력
3.1.3.3.1. map(int, sys.stdin.readline( ).split( ))
3.1.3.4. 임의의 개수의 정수를 한 줄에 입력 & 리스트 저장
3.1.3.4.1. list(map(int, sys.stdin.readline( ).split( )))
3.1.3.5. 임의의 개수의 정수를 n줄 입력 & 리스트 저장
3.1.3.5.1. import sys data = [] n = int (sys.stdin.readline( )) for i in range(n): data.append(list(map(int, sys.stdin.readline( ).split( ))))
3.1.3.6. 문자열 n줄 입력 & 리스트 저장
3.1.3.6.1. import sys n = int(sys.stdin.readline( )) data = [sys.stdin.readline( ).strip( ) for i in range(n)]
3.2. 출력
3.2.1. print
3.2.1.1. str( )
3.2.1.2. ,(공백 생성)ㄹ or +
3.2.1.3. f-string
3.2.1.4. end= ""
4. 논리 연산자
4.1. and, or, not
5. 자료형
5.1. 수
5.1.1. 정수형
5.1.2. 실수형
5.1.2.1. 유효숫자e지수 = 유효숫자 * 10^지수
5.1.2.1.1. 1e9 = 10^9 (10억)
5.1.2.1.2. 75.25e1 = 752.5
5.1.2.1.3. 395e-3 = 3.954
5.1.3. 수 자료형의 연산
5.1.3.1. a/b
5.1.3.2. a%b
5.1.3.3. a//b
5.2. 리스트
5.2.1. 인덱싱
5.2.2. 슬라이싱
5.2.3. 리스트 컴프리헨션
5.2.3.1. [ i*i for in range(20) if i%2 == 1 ]
5.2.3.2. 2차원 리스트 초기화
5.2.3.2.1. [ [0] * m for _ in range(n) ]
5.2.4. 메서드
5.2.4.1. append( )
5.2.4.2. sort(reverse=False)
5.2.4.3. reverse( )
5.2.4.4. insert( )
5.2.4.5. count( )
5.2.4.6. remove( )
5.3. 문자열
5.3.1. 초기화
5.3.2. 연산
5.4. 튜플
5.5. 사전
5.5.1. .keys( )
5.5.2. .values( )
5.6. 집합
5.6.1. set( )
5.6.2. 연산
5.6.2.1. 합집합
5.6.2.1.1. a | b
5.6.2.2. 교집합
5.6.2.2.1. a & b
5.6.2.3. 차집합
5.6.2.3.1. a - b
5.6.3. 함수
5.6.3.1. add( )
5.6.3.2. update( )
5.6.3.3. remove( )
5.7. - 리스트&튜플 : 순서가 존재하므로 인덱싱을 통해 자료형의 값을 얻을 수 있음 - 사전&집합 : 인덱싱X, 키 혹은 집합 원소를 통해 O(1)의 시간복잡도로 조회됨
6. 조건문
6.1. if~elif~else
6.2. 비교 연산자
6.2.1. ==, !=, >, <, >=, <=
6.3. 기타 연산자
6.3.1. in, not in
6.4. pass
6.5. 조건문 간소화
6.5.1. if score>=80 : result = "Success"
6.5.2. 조건부 표현식
6.5.2.1. "Success" if score >=80 else "Fail"
7. 표준 라이브러리
7.1. 내장 함수
7.1.1. input( )
7.1.2. print( )
7.1.3. sum( ), min( ), max( )
7.1.4. eval( )
7.1.5. sorted( )
7.1.5.1. reverse
7.1.5.2. key
7.2. itertools
7.2.1. permutations (순열)
7.2.2. combinations (조합)
7.2.3. product (중복 허용 순열)
7.2.4. combinations_with_replacement (중복 허용 조합)
7.3. heapq
7.3.1. heapq.heappush(h, value)
7.3.2. heapq.heappop
7.3.3. heapsort
7.4. bisect
7.4.1. bisect_left (a, x)
7.4.2. bisect_right (a, x)
7.5. collections
7.5.1. deque
7.5.1.1. popleft( ), pop( )
7.5.1.2. appendleft(x), append(x)
7.5.2. Counter
7.5.2.1. dict(Counter)
7.6. math
7.6.1. 최대 공약수(GCD)
7.6.1.1. math.gcd(a, b)
7.6.2. 최대 공배수(LCM)
7.6.2.1. a*b // math.gcd(a, b)