0
que?
no entiendo la lógica de este código https://code.sololearn.com/cRssCkZA7b64/?ref=app
6 Answers
+ 2
Jaime Vinasco ,
print('a' and '2') # 2
print(('a' and '2') == ('a' and '2')) # True
print(('a' and '2') != ('a' and '2')) # False
+ 1
Por que muestra 2?
0
Pablo Martin ,
print('a' and 'b') # b
print('b' and 'a') # a
print('a' or 'b') # a
print('b' or 'a') # b
My Spanish is insufficient. Search "short-circuit evaluation in Python". Also search "python logical operations with non-boolean values".
Mi español es insuficiente. Busque "evaluación de cortocircuitos en Python". También busque "operaciones lógicas de python con valores no booleanos".
0
'a' and '2' = 2 why 'a'and'2' == 'a'and'2' False it must be True
0
Jaime Vinasco ,
Operator precedence.
print(('a' and '2') == ('a' and '2')) # True
print('a' and ('2' == 'a') and '2') # False
print('a' and '2' == 'a' and '2') # False
https://docs.python.org/3/reference/expressions.html?highlight=precedence#operator-precedence
0
Huhhijj