What will be the output of the following Python function?
any([2>8, 4>2, 1>2])
any([2>8, 4>2, 1>2])A. Error
B. True
C. False
D. 4>2
Answer: Option B
Solution (By Examveda Team)
The any() function in Python returns True if at least one element of the iterable is true, otherwise it returns False.In the provided code, the list [2>8, 4>2, 1>2] contains three boolean expressions:
2>8 evaluates to False.
4>2 evaluates to True.
1>2 evaluates to False.
Since at least one of the expressions (4>2) is true, the any() function returns True.

Join The Discussion