Python Interview questions - sets
(Python version 3.9 or later version)
Which of the following Python objects is immutable?
set
dict
list
str
What would be the result of executing the following code?
print(True*2)
TrueTrue
True True
2
Syntax Error
Python Interview Questions
  • Python - Set
    1. How do you cast the list A to the set a?
    A) a = A.dict()
    B) a = set(A)
    C) a.set()

    Answer: a = set(A)
    2.Consider the Set: V={'1','2'}, what is the result of V.add('3')?
    A) {1,2,3}
    B) {'1','2'}
    C) {'1','2','3'}

    Answer: {'1','2','3'}
    3. What is the result of the following: '1' in {'1','2'}
    A) False
    B) True

    Answer: True
  • gk