목록Records of (68)
SiLaure's Data
- tuple은 list와 거의 같다. => indexing, slicing 모두 동일하게 사용 가능하다. - 다른 점은 2가지 1) 리스트는 [ ] 을 사용하고, 튜플은 ( )을 사용한다. 2) 리스트는 생성 후 변경 가능(mutable), 튜플은 변경 불가능(immutable) 더보기 - Mutable : 생성된 이후에 변경(assignment)이 자유롭게 가능한 data type. e.g. List, dict, set - Immutable : 생성된 이후에 변경이 불가능한 data type e.g. int, float, string, tuple, frozenset => Immuatble data type의 장점 1. 성능적인 이슈 : 변경되지 않는 그 자체가 장점 2. 프로그래밍적인 이슈 : 데이터..
- 얘네들은 sequence type data(연속형 데이터 타입) - 순서 정보로 가져오는 방식이 indexing, 특정 조건에 맞는 정보를 뭉탱이로 가져오는 방식이 slicing 더보기 id(L[ : ]), id(L)의 값이 다르다......?! id(L[ : ]) => copy의 개념 -- rvalue를 다른 주소값에 복사
- 변수에 값을 할당할 때 assignment operator(이하 =) 기준 왼쪽을 lvalue, 오른쪽을 rvalue라고 한다. · lvalue : 실제 메모리 주소 · rvalue : 실제 데이터 또는 값 - rvalue를 보고 assign이 일어날 때 lvalue의 Data type이 결정된다. => dynamic type binding이라고 한다. - Python에서는 (이론 상)변수 할당에 제한이 없다. - Debugging 할 때 최고의 도구는 print() - print formatting · 사용되는 변수의 데이터의 형식을 알 수 있다. - f-string · code가 길어질 경우 변수명을 쓰는 것이 편리하다. · 사용되는 변수의 내용을 알 수 있다. · 출력될 값의 Data type을..
- Slicing (**) : 슬라이싱은 리스트에서 뿐만 아니라, 리스트와 비슷한 구조인 numpy array와 pandas series, dataframe에서도 많이 이용되니 꼭 알아두자. · 슬라이싱은 리스트의 일부분만 잘라낸다는 의미이다. (말 그대로 슬라이싱) · 리스트의 일부만 사용하고 싶을 때 쓰는 기법이며, indexing을 범위로 하는 느낌이다. · 리스트의 index와 : 를 사용하여 슬라이싱을 할 수 있다. e.g. L = [1, 2, 3, 4] 일 때 L[0:2] 는 [1, 2]이다. cf) L[ : : 2]는 2씩 건너 뛰기. => L[0], L[2], ... - 리스트 연산하기 · 리스트 더하기 · 리스트 곱하기 · 리스트 수정하기 · 리스트에 원소 추가하기 append() (**..
- 연속형 데이터 · 연속형 데이터란 하나의 변수가 하나의 데이터를 가지고 있던 숫자형 데이터와 달리, 여러개의 데이터를 하나의 변수에 가지고 있는 데이터 타입이다. · List, Tuple, String이 대표적인 연속형 데이터이다. · 크기 제한은 없으나 사용하는 컴퓨터의 가용 메모리 용량을 인지하여 사용해야 한다. · 각 연속형 데이터 타입마다 특징이 다르다. 그 특징을 파악하여 용도에 맞는 데이터 타입을 사용하는 것이 중요하다. cf) 사전(dictionary) 타입은 associative array라고 불리며, 흔히 알고있는 Hasg table 구조이다. - 리스트(List) · 가장 많이 사용되는 연속형 데디터 타입이자, 굉장히 유연한 구조를 가지고 있어 대부분의 데이터를 편하게 다룰 수 있다..
- 문자열 Formatting · 문자열을 출력할 때*(print 함수를 사용하여) 특정 format을 지정하고 싶은 경우에는 어떻게 해야할까? e.g. OOO님의 주민등록 번호는 XXXXXX-XXXXXXX입니다. · 문자열 포맷에는 크게 3가지가 있으며 기호에 맞게 사용하면 된다. 더보기 1) print format 사용 2) str.format 함수 사용 3) f-string(**) (연습문제) - 문자열 관련 함수들(**) · (영어) 대소문자 바꾸기 : upper(), lower() · 문자 공백 지우기 strip() -- 따옴표 직후/직전의 공백만 적용 · 문자열 삽입 join() · 문자열 나누기 split() · 문자열 바꾸기 replace()
2.2 문자열(Stirng) · 문자열 데이터란 문자(character)의 나열을 의미한다 e.g. "Hello World" > string ; Character Sequence · 파이썬에서 다룰 수 있는 문자열의 크기도 제한이 없다. · 파이썬에서는 ' 와 " 두 가지의 기호를 통해 문자열을 나타낸다. 즉, ' 부터 ' 까지 또는 " 부터 " 까지 하나의 문자열이다. e.g. 'Hello', "World" · 컴퓨터는 문자(character)를 encoding하여 숫자로 표현한다 e.g. ASCII, UTF-8, CP949 > 컴퓨터는 문자를 숫자로 인식한다. > e.g. ASCII 코드로 변환하면 A=>65, a=>97 · 현재 전세계적으로 웹에서 사용되는 국제 표준은 UTF-8(Universal ..
2.1 숫자 데이터 (Numeric Data Types) · 숫자형 데이터란 정수/실수/복소수/2진수/8진수/16진수를 포함하여 가장 많이 사용하는 데이터 타입 중 하나이다. · 파이썬은 숫자의 표현 범위가 무한대이다. · 숫자 데이터는 우리가 알고 있는 대부분의 연산을 그대로 지원한다. (사칙연산, 몫/나머지 구하기, 거듭제곱 등) - 정수형(Integer) · 1+1 · # a에 10, b에 5를 할당하고 더한 결과를 출력 > a=10 > b=5 > a+b > 15 · a-b > 5 - 실수형 (Floating point) > c=3.14 > c+3.14 > 6.28 > # d에 4를 할당하고 c에서 d를 뺀 값을 출력 > d=4 > c-d > -0.859999999999999999999999999...