Set quiz

 

MCQ Quiz on Set Data Type in Python

  1. Which of the following creates an empty set?
    {}
    []
    set()
    empty()

  2. Which feature of a set is correct?
    Ordered collection
    Unordered unique elements
    Allows duplicates
    Supports indexing

  3. What will be the output of {1, 2, 2, 3}?
    {1,2,2,3}
    {1,2,3}
    {2,3}
    Error

  4. Which method is used to add an element to a set?
    add()
    append()
    insert()
    push()

  5. Which method removes an element without raising an error?
    remove()
    discard()
    pop()
    delete()

  6. Which operator performs union?
    &
    -
    |
    ^

  7. Which is NOT a valid set method?
    update()
    intersection()
    difference()
    slice()

  8. What is the output of {1, 2, 3} & {2, 3, 4}?
    {1,4}
    {2,3}
    {1,2,3,4}
    {3,4}

  9. Which operator is used for symmetric difference?
    |
    &
    ^
    %

  10. What will {1,2,3} - {2,3} return?
    {1}
    {2}
    {3}
    {1,2,3}

  11. Which method clears a set?
    removeAll()
    clear()
    delete()
    empty()

  12. The pop() method removes:
    last element
    first element
    random element
    all elements

  13. Which function returns size of a set?
    count()
    length()
    len()
    size()

  14. issubset() returns:
    True/False
    Integer
    New set
    String

  15. Which method returns a shallow copy of a set?
    copy()
    clone()
    replicate()
    duplicate()


Comments

Popular posts from this blog

Topic1 :- What is Python Programming?

Topic2: -Why Python?

Topic7: What is Numpy?