Report Bug

Qus

. What will be the output of the following Python code?

s1={3, 4}

  s2={1, 2}  s3=set()  i=0  j=0  for i in s1:      for j in s2:          s3.add((i,j))          i+=1          j+=1 

print(s3)

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


A. {(3, 4), (1, 2)}
B. Error
C. {(4, 2), (3, 1), (4, 1), (5, 2)}
D. {(3, 1), (4, 2)}


Solution
C. {(4, 2), (3, 1), (4, 1), (5, 2)}



Explanation
The code shown above finds the Cartesian product of the two sets, s1 and s2. The Cartesian product of these two sets is stored in a third set, that is, s3. Hence the output of this code is: {(4, 2), (3, 1), (4, 1), (5, 2)}.
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