

MCQOPTIONS
Saved Bookmarks
This section includes 4 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.
1. |
What will be the output of the following Python code, if s1= {1, 2, 3}? |
A. | True |
B. | Error |
C. | No output |
D. | FalseView Answer |
Answer» B. Error | |
2. |
If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the function: |
A. | s2.issubset(s1) |
B. | s2.issuperset(s1) |
C. | s1.issuperset(s2) |
D. | s1.isset(s2) |
Answer» C. s1.issuperset(s2) | |
3. |
The difference between the functions discard and remove is that: |
A. | Discard removes the last element of the set whereas remove removes the first element of the set |
B. | Discard throws an error if the specified element is not present in the set whereas remove does not throw an error in case of absence of the specified element |
C. | Remove removes the last element of the set whereas discard removes the first element of the set |
D. | Remove throws an error if the specified element is not present in the set whereas discard does not throw an error in case of absence of the specified element |
Answer» E. | |
4. |
The ____________ function removes the first element of a set and the last element of a list. |
A. | remove |
B. | pop |
C. | discard |
D. | dispose |
Answer» C. discard | |