반응형
name = "John"
age = 17
print(name == "John" or not age > 17)
print(name == "John" or not age > 17)
print(name == "Ellis" or not (name == "John" and age == 17)) # Check if "name" is "Ellis" or
it's not true that "name" equal "John" and he is 17 years old at the same time.
산출물 (Output)
True
True
False
* Boolean operators are not evaluated from left to right. There's an order of operations for boolean operators:
"not" is evaluated first, "and" is evaluated next, "or" is evaluated last.
반응형
'Python 배우기' 카테고리의 다른 글
else_elif.py (0) | 2016.03.09 |
---|---|
if_statement.py (0) | 2016.03.08 |
boolean_operators.py (0) | 2016.03.08 |
in_keyword.py (0) | 2016.03.08 |
dict_key_value.py (0) | 2016.03.07 |
댓글