

MCQOPTIONS
Saved Bookmarks
This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your Technical MCQs knowledge and support exam preparation. Choose a topic below to get started.
1. |
set1.add(4) set1.add(4) print(set1) |
A. | print(set1[0]) |
B. | set1[0]=9 |
C. | set1=set1+{7} |
D. | All of the above |
E. | |
Answer» E. | |
2. |
set2={3,2} set3={2,1} if(set1==set2): print("yes") else: print("no") if(set1==set3): print("yes") else: print("no") |
A. | {1,2,3,4} |
B. | {1,2,3} |
C. | {1,2,3,4,4} |
D. | It will throw an error as same element is added twice |
Answer» B. {1,2,3} | |
3. |
set2={3,2} set3={2,1} if(set1==set2): print("yes") else: print("no") if(set1==set3): print("yes") else: print("no") |
A. | set1|set2 |
B. | set1&set2 |
C. | set1-set2 |
D. | None of the above |
Answer» D. None of the above | |
4. |
set1.remove(3) |
A. | Yes, No |
B. | No, No |
C. | Yes, Yes |
D. | "==" is not supported for set in Python |
Answer» B. No, No | |
5. |
|
A. | It removes element with index position 3 from set1 |
B. | It removes element 3 from set1 |
C. | It removes only the first occurance of 3 from set1 |
D. | No such function exists for set |
Answer» C. It removes only the first occurance of 3 from set1 | |
6. |
x=list1.pop(2) print(set([x])) |
A. | Elements of set2 will get appended to set1 |
B. | Elements of set1 will get appended to set2 |
C. | A new set will be created with the elements of both set1 and set2 |
D. | A new set will be created with the unique elements of set1 and set2. |
Answer» D. A new set will be created with the unique elements of set1 and set2. | |
7. |
set2={3,1} set3={} set3=set1&set2 print(set3) |
A. | {1,3,4} |
B. | {1,3,2} |
C. | {2} |
D. | {4} |
Answer» E. | |
8. |
print(set1) |
A. | {3} |
B. | {} |
C. | {2,5,3,1} |
D. | {2,5,1} |
Answer» B. {} | |
9. |
What will be the output of following Python code? |
A. | {0,0,9} |
B. | {0,9} |
C. | {9} |
D. | It will throw an error as there are two 0 while creating the set. |
Answer» C. {9} | |
10. |
Which of the following Python code will create a set? (i) set1=set((0,9,0)) (ii) set1=set([0,2,9]) (iii) set1={} |
A. | iii |
B. | i and ii |
C. | ii, iii |
D. | All of the above |
Answer» E. | |