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

Which of the following statements is used to create an empty set?


Options are :

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

Answer :set()

What will be the output of the following Python code?


Options are :

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

Answer :True

Python Certification Exam Preparation Set 24

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[2]=45

Answer :a[2]=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

Answer :a={5,6,7}

What will be the output of the following Python code?


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

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

What will be the output of the following Python code?


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

Answer :{4,5}

What will be the output of the following Python code?


Options are :

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

Answer :{5,6,10,11}

What will be the output of the following Python code?


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

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

What will be the output of the following Python code?


Options are :

  • True
  • False

Answer :True

What will be the output of the following Python code?


Options are :

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

Answer :{3,4,6,7}

Is the following Python code valid?


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

Answer :Error, subsets aren't allowed

Python Certification Exam Preparation Set 59

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

Answer :Mutable data type

What is the syntax of the following Python code?


Options are :

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

Answer :frozenset({5,6,7})

Is the following Python code valid?


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

Python Certification Exam Preparation Set 27

Set members must not be hashable.


Options are :

  • True
  • False

Answer :False

What will be the output of the following Python code?


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?


Options are :

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

Answer :{2,3}

Python Certification Exam Preparation Set 25

What will be the output of the following Python code?


Options are :

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

Answer :{1,2}

What will be the output of the following Python code?


Options are :

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

Answer :{1,2,3}

What will be the output of the following Python code?


Options are :

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

Answer :Nothing is printed

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

What will be the output of the following Python code?


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})

Answer :{1,2}

What will be the output of the following Python code?


Options are :

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

Answer :23

What will be the output of the following Python code?


Options are :

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

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

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

What will be the output of the following Python code?


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?


Options are :

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

Answer :True

Is the following Python code valid?


Options are :

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

Answer :False

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

What will be the output of the following Python code?


Options are :

  • <'set'>
  • set
  • class set

Answer :

The following Python code results in an error.


Options are :

  • True
  • False

Answer :True

Set makes use of __________


Dictionary makes use of ____________


Options are :

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

Answer :keys, key values

Python Certification Exam Preparation Set 7

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}

Answer :s={san}

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions