  ## Python Practice Test MCQ Certified Go from 0 to Expert hero Set 14

Options are :

• { }
• set()
• [ ]
• ( )

##### What will be the output of the following Python code?`>>> a={5,4}>>> b={1,2,4,5}>>> a<b`

Options are :

• {1,2}
• True
• False
• Invalid operation

##### If a={5,6,7,8}, which of the following statements is false?

Options are :

• print(len(a))
• print(min(a))
• a.remove(5)
• a=45

##### If a={5,6,7}, what happens when a.add(5) is executed?

Options are :

• a={5,5,6,7}
• a={5,6,7}
• Error as there is no add function for set data type
• Error as 5 already exists in the set

##### What will be the output of the following Python code?`>>> a={4,5,6}>>> b={2,8,6}>>> a+b`

Options are :

• {4,5,6,2,8}
• {4,5,6,2,8,6}
• Error as unsupported operand type for sets
• Error as the duplicate item 6 is present in both sets

Answer :Error as unsupported operand type for sets

##### What will be the output of the following Python code?`>>> a={4,5,6}>>> b={2,8,6}>>> a-b`

Options are :

• {4,5}
• {6}
• Error as unsupported operand type for set data type
• Error as the duplicate item 6 is present in both sets

##### What will be the output of the following Python code?`>>> a={5,6,7,8}>>> b={7,8,10,11}>>> a^b`

Options are :

• {5,6,7,8,10,11}
• {7,8}
• Error as unsupported operand type of set data type
• {5,6,10,11}

##### What will be the output of the following Python code?`>>> s={5,6}>>> s*3`

Options are :

• Error as unsupported operand type for set data type
• {5,6,5,6,5,6}
• {5,6}
• Error as multiplication creates duplicate elements which isn't allowed

Answer :Error as unsupported operand type for set data type

Options are :

• True
• False

##### What will be the output of the following Python code?`>>> a={3,4,5}>>> b={5,6,7}>>> a|b`

Options are :

• Invalid operation
• {3, 4, 5, 6, 7}
• {5}
• {3,4,6,7}

##### Is the following Python code valid?`a={3,4,{7,5}}print(a)`

Options are :

• Yes, 7 is printed
• Error, elements of a set can't be printed
• Error, subsets aren't allowed
• Yes, {7,5} is printed

##### Which of these about a frozenset is not true?

Options are :

• Mutable data type
• Allows duplicate values
• Data type with unordered values
• Immutable data type

##### What is the syntax of the following Python code?`>>> a=frozenset(set([5,6,7]))>>> a`

Options are :

• {5,6,7}
• frozenset({5,6,7})
• Error, not possible to convert set into frozenset
• Syntax error

##### Is the following Python code valid?`>>> a=frozenset([5,6,7])>>> a>>> a.add(5)`

Options are :

• Yes, now a is {5,5,6,7}
• No, frozen set is immutable
• No, invalid syntax for add method
• Yes, now a is {5,6,7}

Answer :No, frozen set is immutable

Options are :

• True
• False

##### What will be the output of the following Python code?`>>> a={3,4,5}>>> a.update([1,2,3])>>> a`

Options are :

• Error, no method called update for set data type
• {1, 2, 3, 4, 5}
• Error, list can't be added to set
• Error, duplicate item present in list

Answer :{1, 2, 3, 4, 5}

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> a.intersection_update({2,3,4,5})>>> a`

Options are :

• {2,3}
• Error, duplicate item present in list
• Error, no method called intersection_update for set data type
• {1,4,5}

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> b=a>>> b.remove(3)>>> a`

Options are :

• {1,2,3}
• Error, copying of sets isn't allowed
• {1,2}
• Error, invalid syntax for remove

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> b=a.copy()>>> b.add(4)>>> a`

Options are :

• {1,2,3}
• Error, invalid syntax for add
• {1,2,3,4}
• Error, copying of sets isn't allowed

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> b=a.add(4)>>> b`

Options are :

• 0
• {1,2,3,4}
• {1,2,3}
• Nothing is printed

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> b=frozenset([3,4,5])>>> a-b`

Options are :

• {1,2}
• Error as difference between a set and frozenset can't be found out
• Error as unsupported operand type for set data type
• frozenset({1,2})

##### What will be the output of the following Python code?`>>> a={5,6,7}>>> sum(a,5)`

Options are :

• 5
• 23
• 18
• Invalid syntax for sum method, too many arguments

##### What will be the output of the following Python code?`>>> a={1,2,3}>>> {x*2 for x in a|{4,5}}`

Options are :

• {2,4,6}
• Error, set comprehensions aren't allowed
• {8, 2, 10, 4, 6}
• {8,10}

Answer :{8, 2, 10, 4, 6}

##### What will be the output of the following Python code?`>>> a={5,6,7,8}>>> b={7,8,9,10}>>> len(a+b)`

Options are :

• 8
• Error, unsupported operand '+' for sets
• 6
• Nothing is displayed

Answer :Error, unsupported operand '+' for sets

##### What will be the output of the following Python code?`a={1,2,3}b={1,2,3}c=a.issubset(b)print(c)`

Options are :

• True
• Error, no method called issubset() exists
• Syntax error for issubset() method
• False

##### Is the following Python code valid?`a={1,2,3}b={1,2,3,4}c=a.issuperset(b)print(c)`

Options are :

• False
• True
• Syntax error for issuperset() method
• Error, no method called issuperset() exists

Options are :

• <'set'>
• set
• class set

Options are :

• True
• False

##### Set makes use of __________Dictionary makes use of ____________

Options are :

• keys, keys
• key values, keys
• keys, key values
• key values, key values

##### Which of the following lines of code will result in an error?

Options are :

• s={abs}
• s={4, 'abc', (1,2)}
• s={2, 2.2, 3, 'xyz'}
• s={san}