Which of these about a set is not true?
a) Mutable data type
b) Does not allow duplicate values
c) Data type with unordered values
d) Immutable data type
Explanation: A set is a mutable data type with non-duplicate, unordered values, providing the usual mathematical set operations.
Which of the following is not the correct syntax for creating a set?
a) set([[1,2],[3,4]])
b) set([1,2,2,3,4])
c) set((1,2,3,4))
d) {1,2,3,4}
Explanation: The argument given for the set must be an iterable.
What will be the output of the following Python code?
a) 7
b) Error, invalid syntax for formation of set
c) 4
d) 8
Explanation: A set doesn’t have duplicate items.
What will be the output of the following Python code?
a) 5 5 6
b) 5 6 7
c) 5 5 6 7 7 7
d) 5 6 7 7 7
Explanation: The filter function will return all the values from list a which are true when passed to function test. Since all the members of the set are non-duplicate members of the list, all of the values will return true. Hence all the values in the list are printed.
Which of the following statements is used to create an empty set?
a) { }
b) set()
c) [ ]
d) ( )
Explanation: { } creates a dictionary not a set. Only set() creates an empty set.
What will be the output of the following Python code?
a) {1,2}
b) True
c) False
d) Invalid operation
Explanation: a<b returns True if a is a proper subset of b.