본문 바로가기
Python 배우기

boolean_operators.py

by 노화방지 Anti-aging Hairstyle 2016. 3. 8.
반응형
name = "John"
age = 17

print(name == "John" or age == 17) # checks that either name equals to "John" OR age equals to 17

print(name == "John" and age != 23) # Check if "name" is equal to "John" and he is not 23 years old.


산출물 (Output)

True
True


* Boolean operators compare statements and return results in boolean values.
The boolean operator "and" returns True when the expressions on both sides of "and" are True.
The boolean operator "or" returns True when at least one expression on either side of "or" is True.
The boolean operator "not" inverts the boolean expression it precedes.


반응형

'Python 배우기' 카테고리의 다른 글

if_statement.py  (0) 2016.03.08
boolean_order.py  (0) 2016.03.08
in_keyword.py  (0) 2016.03.08
dict_key_value.py  (0) 2016.03.07
dicts.py  (0) 2016.03.07

댓글