Report Bug

Qus

What will be the output of the following Python code?

a = [5,5,6,7,7,7]

  b = set(a)  def test(lst):      if lst in b:          return 1      else:          return 0  for i in  filter(test, a)

print(i,end=" ")

Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. 5 5 6
B. 5 6 7
C. 5 5 6 7 7 7
D. 5 6 7 7 7


Solution
C. 5 5 6 7 7 7



Explanation
The filter function will return all the values from list a which are true when passed to function test. Since all the members of the set are non-duplicate members of the list, all of the values will return true. Hence all the values in the list are printed.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz