What will be the output of the following Python code snippet? [code]z=set('abc') z.add('san') z.update(set(['p', 'q'])) z[/code]

What will be the output of the following Python code snippet?
Code:
z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
z
A. {‘abc’, ‘p’, ‘q’, ‘san’}
B. {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
C. {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}
D. {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
 
Answer: d
Explanation: The code shown first adds the element ‘san’ to the set z. The set z is then updated and two more elements, namely, ‘p’ and ‘q’ are added to it. Hence the output is: {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
 

Tìm kiếm

Back
Top