강의

멘토링

커뮤니티

Inflearn Community Q&A

nandilee14751's profile image
nandilee14751

asked

Python, just for fun

Logical Operators Explained with Examples

print(not A or B) 가 Ture인 이유

Written on

·

546

0

not은 반대로 나오는데요.

A or B는 Ture 고 not은 반대니 False가 나와야 한다고 생각했는데 Ture가 나온 이유를 알 수 있을까요?

논리연산자python

Answer 1

1

gyul님의 프로필 이미지
gyul
Instructor

안녕하세요~ 

A 는 True 이고 B도 True입니다. 

A or B는 당연히 True겠죠?

not A or B는 왜 True 일까요? 

그 이유는 or 연산자는 A or B 둘중 하나만 True여도 참(True) 라고 판단을 하기 때문입니다. 

알려주신 예제에서 

'not A' 는 False 이고요, 'B'는 True 입니다. 

즉 `False or True` 인 것이죠. 둘중 하나만 True여도 참이기 때문에 True가 되는 것이랍니다. 

nandilee14751's profile image
nandilee14751

asked

Ask a question