파이썬

[파이썬] 불리언 연산 순서

suky_da 2024. 1. 16. 19:16
True or True and False

 

답은 'True' 

 

그 이유는 or 연산보다 and 연산이 우선하기 때문

 

위의 식을 보다 인간의 눈에 이해하기 쉽게 작성하면 다음과 같다. 

 

True or (True and False)

#괄호 안을 연산하면
True or False
>>True

 

 

 

참고: kaggle-Learn Tutorial Python - Booleans and Conditionals

https://www.kaggle.com/code/colinmorris/booleans-and-conditionals

 

Booleans and Conditionals

Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources

www.kaggle.com