NIELIT O Level Exam

What is the list comprehension equivalent for: list(map(lambda x:x**-1, [1, 2, 3]))?

What is the list comprehension equivalent for: list(map(lambda x:x**-1, [1, 2, 3]))?

लिस्ट काम्प्रीहेन्शन के लिए इक्विवलन्ट क्या है: लिस्ट (मैप (लंब x: x ** - 1, [1, 2, 3]))?

A. [1|x for x in [1, 2, 3]]

B. [-1**x for x in [1, 2, 3]]

C. [x**-1 for x in [1, 2, 3]]

D. [x^-1 for x in range(4)]




Correct Answer is :

C. [x**-1 for x in [1, 2, 3]]



Explanation
The output of the function list(map(lambda x:x**-1, [1, 2, 3])) is [1.0, 0.5, 0.3333333333333333] and that of the list comprehension [x**-1 for x in [1, 2, 3]] is [1.0, 0.5, 0.3333333333333333]. Hence the answer is: [x**-1 for x in [1, 2, 3]].
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad