+ 2

What is the output? How does it work mechanism? For Your Information:

A =["a", "b", True, "c", False] print("a" in arr) # return True print(("a" in arr) in arr # return true print((Bool(None) in arr) in arr # return True # since it works based on the presence of () which give a priority to the sequence of arithmetic operation to conduct.

12th Nov 2024, 3:40 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
3 Respostas
+ 5
Let's start Oliver Pasaribu . with there is either no A array or no arr array so let's correct this as arr =["a", "b", True, "c", False] print("a" in arr) # return True print(("a" in arr) in arr ) # return True print((bool(None) in arr) in arr ) # return True Is 'a' in the array yes ( True ) Is 'a' in the array yes True and is True in the arr -> the answer is yes ( True ) bool(None) expression evaluates to False and yes False is in the array so True and is True in the array yes so the answer is True In conclusion all 3 statements are True
12th Nov 2024, 8:01 AM
BroFar
BroFar - avatar
+ 4
Oliver Pasaribu , what exactly is your question?
12th Nov 2024, 6:37 AM
Lothar
Lothar - avatar
+ 2
Yes. You right Brofar. We are thinking on the same way.
12th Nov 2024, 8:06 AM
Oliver Pasaribu
Oliver Pasaribu - avatar