निम्नलिखित कोड स्निपेट का आउटपुट क्या होगा?
What will be the output of the following code snippet ?
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
odd_numbers = [x for x in sorted_numbers if
x % 2 != 0]
print(odd_numbers)
A)
B)
C)
D)
Explanation:
Here’s how the code works:
- The tuple
numbers
is sorted:[2, 4, 7, 19, 22, 45, 72, 89]
. - It then filters out the odd numbers:
[7, 19, 45, 89]
. - Finally, it prints the list of odd numbers.
Output: [7, 19, 45, 89]
Answer: (A)