
Python에서의 데이터 타입(Data Types)은 프로그램에서 다룰 수 있는 다양한 종류의 데이터를 구분하고 처리하는 기본 개념입니다. 이번 강의에서는 Python에서 자주 사용되는 데이터 타입과, 이들을 어떻게 변환(casting)하고 활용하는지 배웁니다.
type(11) # <class 'int'>
type(3.14) # <class 'float'>
type("Python") # <class 'str'>
Python에서는 한 타입에서 다른 타입으로의 변환을 casting이라고 합니다.
float(2) # 2.0
int(1.1) # 1
int("1") # 1
"A1" 같은 문자열은 변환 시 오류 발생
str(3) # '3'
str(2.5) # '2.5'
type(True) # <class 'bool'>
type(False) # <class 'bool'>
int(True) # 1
int(False) # 0
bool(1) # True
bool(0) # False
| 데이터 타입 | 설명 | 예시 |
|---|---|---|
| int | 정수형 | 11, -3 |
| float | 실수형 | 21.213, 0.5 |
| str | 문자열 | "Hello" |
| bool | 불리언 | True, False |