Report Bug

Qus

What will be the output of the following Python code?

  l=[1,2,3,4,5]  [x&1 for x in l]
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. [1, 1, 1, 1, 1]
B. [1, 0, 1, 0, 1]
C. [1, 0, 0, 0, 0]
D. [0, 1, 0, 1, 0]


Solution
B. [1, 0, 1, 0, 1]



Explanation
In the code shown above, each of the numbers of the list, that is, 1, 2, 3, 4 and 5 are AND-ed with 1 and the result is printed in the form of a list. Hence the output is [1, 0, 1, 0, 1].
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad