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

What will be the output of the following Python code?


Options are :

  • {2, 5, 7}
  • {2, 5, 6, 7}
  • {2, 5, 6, 6, 7}
  • Error

Answer :{2, 5, 6, 7}

Input order is preserved in sets.


Options are :

  • True
  • False

Answer :False

Python Certification Exam Preparation Set 29

Write a list comprehension for number and its cube for:


Options are :

  • [x**3 for x in l]
  • [x^3 for x in l]
  • [x**3 in l]
  • [x^3 in l]

Answer :[x**3 for x in l]

What will be the output of the following Python code?


Options are :

  • {1, 2, 3, 4}
  • {1, 2, 4, 3}
  • {4, 1, 2, 3}
  • Error

Answer :Error

Which of the following functions cannot be used on heterogeneous sets?


Options are :

  • pop
  • remove
  • uodate
  • sum

Answer :sum

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

What will be the output of the following Python code?


Options are :

  • True False
  • False True
  • True True
  • False False

Answer :False True

Which of the following functions will return the symmetric difference between two sets, x and y?


Options are :

  • x | y
  • x ^ y
  • x & y
  • x y

Answer :x & y

What will be the output of the following Python code snippet?


Options are :

  • True
  • False
  • No output
  • Error

Answer :True

Python Certification Exam Preparation Set 50

What will be the output of the following Python code snippet?


Options are :

  • {'abc', 'p', 'q', 'san'}
  • {'a', 'b', 'c', ['p', 'q'], 'san}
  • {'a', 'c', 'c', 'p', 'q', 's', 'a', 'n'}
  • {'a', 'b', 'c', 'p', 'q', 'san'}

Answer :{'a', 'b', 'c', 'p', 'q', 'san'}

What will be the output of the following Python code snippet?


Options are :

  • {1, 2, 3, 4, 5} {1, 2, 3, 4, 5}
  • Error {1, 2, 3, 4, 5}
  • {1, 2, 3, 4, 5} Error
  • Error Error

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

What will be the output of the following Python code snippet?


Options are :

  • pp qq rr
  • pqr pqr
  • ppqqrr
  • pqrpqr

Answer :pp qq rr

Python Certification Exam Preparation Set 22

What will be the output of the following Python code snippet?


Options are :

  • {1, 4, 9, 16}
  • {0, 1, 4, 9, 16}
  • Error
  • {0, 1, 4, 9}

Answer :{0, 1, 4, 9}

What will be the output of the following Python function?


Options are :

  • {abc} aaa bbb ccc
  • abc abc abc abc
  • {'a', 'b', 'c'} {'aaa', 'bbb', 'ccc'}
  • {'a', 'b', 'c'} abc abc abc

Answer : {'a', 'b', 'c'} {'aaa', 'bbb', 'ccc'}

The output of the following code is: class<'set'>.


Options are :

  • True
  • False

Answer :False

Python Certification Exam Preparation Set 21

What will be the output of the following Python code snippet?


Options are :

  • True False
  • False False
  • False True
  • True True

Answer : False True

What will be the output of the following Python code snippet?


Options are :

  • {1, 2, 4, 5, 2, 'xy', 4} [1, 2, 4, 5, 2, 'xy', 4]
  • {1, 2, 4, 5, 'xy'} [1, 2, 4, 5, 2, 'xy', 4]
  • {1, 5, 'xy'} [1, 5, 'xy']
  • {1, 2, 4, 5, 'xy'} [1, 2, 4, 5, 'xy']

Answer :{1, 2, 4, 5, 'xy'} [1, 2, 4, 5, 2, 'xy', 4]

What will be the output of the following Python code?


Options are :

  • {(3, 4), (1, 2)}
  • Error
  • {(4, 2), (3, 1), (4, 1), (5, 2)}
  • {(3, 1), (4, 2)}

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

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

The ____________ function removes the first element of a set and the last element of a list.


Options are :

  • remove
  • pop
  • discard
  • dispose

Answer :pop

The difference between the functions discard and remove is that:


Options are :

  • Discard removes the last element of the set whereas remove removes the first element of the set
  • 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
  • Remove removes the last element of the set whereas discard removes the first element of the set
  • 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 :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

What will be the output of the following Python code?


Options are :

  • {1, 2} {4, 5, 6}
  • {1, 2} {1, 2}
  • {4, 5, 6} {1, 2}
  • {4, 5, 6} {4, 5, 6}

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

Python Certification Exam Preparation Set 47

What will be the output of the following Python code?


Options are :

  • True False
  • False True
  • True True
  • False False

Answer :True True

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:


Options are :

  • s2.issubset(s1)
  • s2.issuperset(s1)
  • s1.issuperset(s2)
  • s1.isset(s2)

Answer :s2.issuperset(s1)

What will be the output of the following Python code?


Options are :

  • {3} {1, 2, 3, 4, 5, 6, 8}
  • {1, 2, 4, 5, 6, 8} {1, 2, 4, 5, 6, 8}
  • {3} {3}
  • {1, 2, 3, 4, 5, 6, 8} {1, 2, 3, 4, 5, 6, 8}

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

Python Certification Exam Preparation Set 53

What will be the output of the following Python code?


Options are :

  • set() ('e', 'd', 'f'}
  • {} {}
  • {'b', 'c', 'a'} set()
  • set() set()

Answer :{'b', 'c', 'a'} set()

What will be the output of the following Python code, if s1= {1, 2, 3}?


Options are :

  • True
  • Error
  • No outout
  • False

Answer :True

What will be the output of the following Python code?


Options are :

  • {'a', 'b', 'c', 'd', 'e'} {'x', 'y', 'z'}
  • {'a', 'c', 'e'} {'x', 'y', 'z', 'b', 'd'}
  • {'b', 'd'} {'b', 'd'}
  • {'a', 'c', 'e'} {'x', 'y', 'z'}

Answer :{'a', 'c', 'e'} {'x', 'y', 'z', 'b', 'd'}

Python Certification Exam Preparation Set 56

Which of the following statements create a dictionary?


Options are :

  • d = {}
  • d = {"john":40, "peter":45}
  • d = {40:"john", 45:"peter"}
  • All of the mentioned

Answer :All of the mentioned

What will be the output of the following Python code snippet?


Options are :

  • "john", 40, 45, and "peter"
  • "john" and "peter"
  • 40 and 45
  • d = (40:"john", 45:"peter")

Answer :"john" and "peter"

What will be the output of the following Python code snippet?


Options are :

  • True
  • False
  • None
  • Error

Answer :True

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

What will be the output of the following Python code snippet?


Options are :

  • True
  • False
  • None
  • Error

Answer :False

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions