01 Python 기초 배우기 - (7) operator

처어리·2024년 1월 17일

python

목록 보기
8/36
post-thumbnail

07. operator

산술연산자

  • Code
data1, data2 = 4, 3
print(f"{data1} ** {data2} = {data1**data2}")   # 거듭 제곱
print(f"{data1} // {data2} = {data1//data2}")   # 나누셈 결과의 몫을 구하는 연산자
  • Console

not : 참 또는 거짓에 대한 부정

  • Code
data1, data2 = 4, 3
not True
not False
print(f"not {data1} > {data2} : {not data1>data2}")
  • Console

멤버연산자

n in () : () 안의 데이터 중에 n 의 값이 있는지 확인

  • Code
print(f"{data1} in (1, 2, 3, 4, 5) : {data1 in (1, 2, 3, 4, 5)}")
  • Console

n not in () : () 안의 데이터중에 n의 값이 없는지 확인

  • Code
print(f"{data1} not in (1, 2, 3, 4, 5) : {data1 not in (1, 2, 3, 4, 5)}")
  • Console

식별 연산자

type() is 자료형

  • Code
print(f'type({data1} is int : {type(data1) is int})')
print(f'type({data1} is float : {type(data1) is float})')
  • Console

논리연산자

  • and : 모든 값이 참인 경우에 참

  • or : 모든 값이 거짓이면 거짓

0개의 댓글