06 built-in-type
| 4 Minute Read on Python
Built-in Types¶
- Built-in Types docs 보면 다음과 같은 Python의 기본 자료형을 확인할 수 있다.
- Boolean Types: 참(True) 또는 거짓(False) 값 또는 1과 0의 숫자값으로도 표현
- Numeric Types: int(정수), float(실수), complex(복소수)
- Iterator Types: iter(), next()(컨테이너 또는 이터레이터에 대하여 반복
- Sequence Types: list, tuple, range (산술연산, indexing 같은 Sequence Operations을 수행)
- Text Sequence Type:str (String Methods를 수행)
- Set Types:set, frozentset(정렬되지 않은 유일한 개체의 모음)
- Mapping Types:dictionary(연관배열의 키와 값의 쌍의 집합형 자료형
- 변경 가능형 : list, dict, set 변경 불가능형 : int, float, complex, bool, tuple, str
Boolean Types¶
In [1]:
a = True
print(type(a))
print(bool(a))
In [2]:
b = False
print(type(b))
print(bool(b))
Numeric Types¶
In [3]:
# Python에는 정수나 실수형도 객체로 인식한다.
c = 3
print(type(c))
d = 3.3
print(type(d))
Iterator Types¶
In [4]:
x = [1,2,3]
type(x)
y = iter(x)
print(type(y))
print(next(y))
print(next(y))
print(next(y))
Sequence Types¶
In [5]:
a = list(range(1, 6))
print(a)
Text Sequence Type¶
In [6]:
a = 'abcde'
for i in a:
print(i)
Set Type¶
In [7]:
s = set (i for i in range(1, 6))
print(s)
Mapping Types¶
In [8]:
a = {'k':'v','k2':3}
a.items()
Out[8]: