Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Archives
Today
Total
관리 메뉴

RUBY

논리 연산자 본문

프로그래밍 언어/Python

논리 연산자

ruby-jieun 2023. 1. 3. 17:53

 

 

 

논리 연산자

 


  • 논리 연산자란, 피연산자의 논리(True, False)를 이용한 연산
    논리 연산자 종류 : and, or, not

 

  • and 연산
    A and B : A와 B 모두 True인 경우만 결과값으로 True이다.
print('{} and {} : {}' .format(True, True, (True and True)))
print('{} and {} : {}' .format(False, True, (False and True)))
print('{} and {} : {}' .format(True, False, (True and False)))
print('{} and {} : {}' .format(False, False, (False and False)))
True and True : True
False and True : False
True and False : False
False and False : False

 

  • or 연산
    A or B : A와 B중 어느 하나만 True이면 결과 값은 True이다.
print('{} or {} : {}' .format(True, True, (True or True)))
print('{} or {} : {}' .format(False, True, (False or True)))
print('{} or {} : {}' .format(True, False, (True or False)))
print('{} or {} : {}' .format(False, False, (False or False)))
True or True : True
False or True : True
True or False : True
False or False : False

 

  • not 연산
    not A : A의 상태를 부정하는 결과를 나타낸다.
print('not {} : {}' .format(True, (not True)))
print('not {} : {}' .format(False, (not False)))
not True : False
not False : True

 

'프로그래밍 언어 > Python' 카테고리의 다른 글

조건식  (0) 2023.01.04
Operator 모듈  (0) 2023.01.04
비교 연산자 2  (0) 2023.01.03
비교 연산자  (0) 2023.01.03
복합 연산자  (0) 2023.01.03
Comments