Set members must not be hashable.
a) True
b) False
Explanation: Set members must always be hashable.
What will be the output of the following Python code?
a) Error, no method called update for set data type
b) {1, 2, 3, 4, 5}
c) Error, list can’t be added to set
d) Error, duplicate item present in list
Explanation: The method update adds elements to a set.
What will be the output of the following Python code?
a) {2,3}
b) Error, duplicate item present in list
c) Error, no method called intersection_update for set data type
d) {1,4,5}
Explanation: The method intersection_update returns a set which is an intersection of both the sets.
What will be the output of the following Python code?
a) {1,2,3}
b) Error, copying of sets isn’t allowed
c) {1,2}
d) Error, invalid syntax for remove
Explanation: Any change made in b is reflected in a because b is an alias of a.
What will be the output of the following Python code?
a) {1,2,3}
b) Error, invalid syntax for add
c) {1,2,3,4}
d) Error, copying of sets isn’t allowed
Explanation: In the above piece of code, b is barely a copy and not an alias of a. Hence any change made in b isn’t reflected in a.
What will be the output of the following Python code?
a) 0
b) {1,2,3,4}
c) {1,2,3}
d) Nothing is printed
Explanation: The method add returns nothing, hence nothing is printed.