0

que?

no entiendo la lógica de este código https://code.sololearn.com/cRssCkZA7b64/?ref=app

19th Dec 2023, 5:44 PM
Jaime Vinasco
Jaime Vinasco - avatar
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
20th Dec 2023, 11:50 AM
Rain
Rain - avatar
+ 1
Por que muestra 2?
20th Dec 2023, 3:06 PM
Pablo Martin
Pablo Martin - avatar
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".
20th Dec 2023, 8:35 PM
Rain
Rain - avatar
0
'a' and '2' = 2 why 'a'and'2' == 'a'and'2' False it must be True
21st Dec 2023, 3:38 AM
Jaime Vinasco
Jaime Vinasco - avatar
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
21st Dec 2023, 4:07 AM
Rain
Rain - avatar
0
Huhhijj
21st Dec 2023, 10:46 AM
nullnull8
nullnull8 - avatar