Boolean Expressions
>>>'a' == ('a' or 'b') # Look at parentheses first, so evaluate expression "('a' or
'b')"
# 'a' is a nonempty string, so the first
value is True
# Return that first value: 'a'
>>>'a' == 'a' # the string 'a' is equivalent to the string 'a', so
expression is True
Second case:
>>>'b' == ('a' or 'b') # Look at parentheses first, so evaluate expression "('a' or
'b')"
# 'a' is a nonempty string, so the first
value is True
# Return that first value: 'a'
>>>'b' == 'a' # the string 'b' is not equivalent to the string 'a',
so expression is False
False
Third case
Fourth case:
>>>'b' == ('a' and 'b') # Look at parentheses first, so evaluate expression "('a' and
'b')"
# 'a' is a nonempty string, so the first
value is True, examine second value
# 'b' is a nonempty string, so second
value is True
# Return that second value as result of
whole expression: 'b'
>>>'b' == 'b' # the string 'b' is equivalent to the string 'b', so
expression is True
True
Subscribe to:
Post Comments (Atom)
It’s Official! Buhari Wins 2019 Election
President Muhammadu Buhari has won the 2019 presidential election, polling 15,191,847 votes to defeat his closest rival, Alhaji Atiku ...
Popular Posts
-
Filed Under Engineering & Neuroscience When is the Tesla Model 3 coming? sign up A new era of computing just got clos...
-
Some gunmen in the wee hours of Wednesday launched an attack on a police patrol vehicle in Rivers State, killing two policemen and injurin...
No comments:
Post a Comment