Vidyalelo
Python · Q11

Python Built

Programming · Python · question 11

Q11

What will be the output of the following Python function? any([2>8, 4>2, 1>2])

A.
Error
B.
True
Answer
C.
False
D.
4>2

Answer: Option B

Solution

Answer: Option B
Solution:
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.