🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड का आउटपुट क्या है?

What is the output of following code ?

a=set('abc')
b=set('cd')
print(a^b)
A)
B)
C)
D)

Explanation:

Let's break down the code:

a = set('abc')  # Converts string 'abc' to a set: {'a', 'b', 'c'}
b = set('cd')   # Converts string 'cd' to a set: {'c', 'd'}
print(a ^ b)     # The symmetric difference between sets a and b

Explanation:

  • Set a is {'a', 'b', 'c'}.
  • Set b is {'c', 'd'}.
  • a ^ b is the symmetric difference of sets a and b, which includes all elements that are in either a or b but not in both.

The elements that are in either a or b but not both are:

  • 'a' and 'b' from set a.
  • 'd' from set b.

So, the result of a ^ b will be {'a', 'b', 'd'}.

Answer:

(C) {'b', 'a', 'd'}

Latest Updates