값이 어떤 자료형인지 확실하지 않을 때, type 함수를 사용한다.
ex) 활용 1
In
print(type(3))
print(type(3.0))
print(type("3"))
Out
<class 'int'> #정수형
<class 'float'> #소수형
<class 'str'> #문자열
ex) 활용 2
In
print(type("Ture"))
print(type(True))
Out
<class 'str'>
<class 'bool'>
ex) 활용 3
In
def hi():
print("HI")
print(type(hi))
print(type(print))
Out
<class 'function'> #함수도 하나의 자료형
<class 'builtin_function_or_method'> #내장 함수