본문 바로가기
PYTHON

[PYTHON] 멤버연산자

by kwh_coding 2023. 6. 28.
# 멤버 연산자
#  - 우측의 데이터들 중에 좌측 데이터가 있는지를 확인하는 연산자

#  데이터 in (데이터,데이터,데이터)

#  - 우측의 데이터들 중에 좌측 데이터가 없는지를 확인하는 연산자
#  데이터 not in (데이터,데이터,데이터)

a = 1

b,c,d,e = 1,2,3,4

tp = b,c,d,e

print(a in tp)

print(a in (b,c,d,e))
print(a in (1,2,3,4))
print(a in (2,3,4))

print(a not in (1,2,3,4))
print(a not in (2,3,4))

# -----------------------------------------------------------------------

# 식별연산자
#  - 데이터의 타입이 맞으면 True 다르면 False
#     type(변수,데이터) is 자료형

#  - 데이터의 타입이 맞으면 False 다르면 True
#     type(변수,데이터) is not 자료형

# type(변수,데이터) - 자료형을 알려주는 함수

# - 나중에 예외에서 사용이 된다

print(type(a))

b = 1.234
print(type(b))

c = True

print(type(c))

print(type(a) is int)
print(type(c) is not int)

'PYTHON' 카테고리의 다른 글

[PYTHON] 타입 일치, 불일치  (0) 2023.06.28
[PYTHON] 유용한 연산 함수  (0) 2023.06.28
[PYTHON] 비교연산자  (0) 2023.06.28
[PYTHON] 변수선언  (0) 2023.06.28
[PYTHON] 기본 서식문자  (0) 2023.06.28