A

Admin • 833K Points
Coach

Q. What is the output of the following code when executed in Python shell?

Code:
>>> d = {1,2,3}
>>> d.intersection_update({2,3,4,5})
>>> d
  • (A) {2,3}
  • (B) Error, duplicate element in the list
  • (C) {1,4,5}
  • (D) Error, no method called intersection_update
  • Correct Answer - Option(A)
  • Views: 29
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

The intersection_update method returns a set that contains the intersection of the two sets.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.