Guidelines
Practice
Guidelines

변수와 값의 자료형을 확인하는 방법

type() 함수는 변수나 값의 자료형을 확인할 때 사용합니다.


type() 함수의 기본 사용

type() 함수는 괄호 안에 변수나 값을 넣고 호출해 해당 데이터의 자료형을 반환합니다.

type() 함수 사용법
number = 10 # 변수 number에 정수 10 할당 print(type(number)) # <class 'int'> : 정수형(Integer) 자료형 text = "파이썬 프로그래밍" # 변수 text에 문자열 할당 print(type(text)) # <class 'str'> : 문자열(String) 자료형

다양한 자료형 확인

type() 함수는 파이썬의 모든 기본 자료형 및 사용자 정의 자료형의 타입을 확인할 수 있습니다.

다양한 자료형 확인
is_active = True print(type(is_active)) # <class 'bool'> : 불린형(Boolean) 자료형 my_list = [1, 2, 3] print(type(my_list)) # <class 'list'> : 리스트(List) 자료형 my_dict = {"key": "value"} print(type(my_dict)) # <class 'dict'> : 딕셔너리(Dictionary) 자료형

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help