• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Python Sets Quiz

Question 1

Question 1: What is the output of the following program? Python3
sets = {1, 2, 3, 4, 4} 
print(sets) 
  • {1, 2, 3}
  • {1, 2, 3, 4}
  • {1, 2, 3, 4, 4}
  • Error

Question 2

Question 2: What is the output of the following program? Python3
sets = {3, 4, 5} 
sets.update([1, 2, 3]) 
print(sets) 
  • {1, 2, 3, 4, 5}
  • {3, 4, 5, 1, 2, 3}
  • {1, 2, 3, 3, 4, 5}
  • Error

Question 3

Question 3: What is the output of the following program? Python3
set1 = {1, 2, 3} 
set2 = set1.copy() 
set2.add(4) 
print(set1) 
  • {1, 2, 3, 4}
  • {1, 2, 3}
  • Invalid Syntax
  • Error

Question 4

Question 4: What is the output of the following program? Python3
set1 = {1, 2, 3} 
set2 = set1.add(4) 
print(set2) 
  • {1, 2, 3, 4}
  • {1, 2, 3}
  • Invalid Syntax
  • None

Question 5

Question 5: What is the output of the following program? Python3
set1 = {1, 2, 3} 
set2 = {4, 5, 6} 
print(len(set1 + set2)) 
  • 3
  • 6
  • Unexpected
  • Error

Question 6

Question 6: What is the output of the following program? Python3
A = {0, 2, 4, 6, 8}; 
B = {1, 2, 3, 4, 5}; 

print(A | B) 
  • {0, 1, 2, 3, 4, 5}
  • {0, 1, 2, 3, 4, 5, 6, 8}
  • { 6, 8}
  • None

Question 7

Question 7: What is the output of the following program? Python3
A = {0, 2, 4, 6, 8}; 
B = {1, 2, 3, 4, 5}; 


print(A & B) 
  • {0, 1, 2, 3, 4, 5, 6, 8}
  • {0, 1, 3, 5, 6, 8}
  • {2, 4}
  • {0, 8, 6}

Question 8

Question 8: What is the output of the following program? Python3
A = {0, 2, 4, 6, 8}; 
B = {1, 2, 3, 4, 5}; 

print( A - B)
  • {0, 1, 2, 3, 4, 5, 6, 8}
  • {0, 8, 6}
  • {2, 4}
  • {0, 1, 3, 5, 6, 8}

Question 9

Question 9: What is the output of the following program? Python3
A = {0, 2, 4, 6, 8}; 
B = {1, 2, 3, 4, 5}; 

print( A ^ B) 
  • {0, 1, 2, 3, 4, 5, 6, 8}
  • {2, 4}
  • {0, 8, 6}
  • {0, 1, 3, 5, 6, 8}

Question 10

Question 10: What is the output of the following program? Python3
set1 = set([1, 2, 4, 4, 3, 3, 3, 6, 5]) 

print(set1) 
  • {1, 2, 4, 4, 3, 3, 3, 6, 5}
  • {1, 2, 3, 4, 5, 6}
  • [1, 2, 3, 4, 5, 6]
  • [1, 2, 4, 4, 3, 3, 3, 6, 5]

There are 11 questions to complete.

Last Updated :
Take a part in the ongoing discussion