adplus-dvertising
frame-decoration

Question

What is the output of the code shown below?
l=[1, 2, 4, 5, 2, 'xy', 4]
set(l)
l

a.

{1, 2, 4, 5, 2, ‘xy’, 4}
[1, 2, 4, 5, 2, ‘xy’, 4]

b.

{1, 2, 4, 5, ‘xy’}
[1, 2, 4, 5, 2, ‘xy’, 4]

c.

{1, 5, ‘xy’}
[1, 5, ‘xy’]

d.

{1, 2, 4, 5, ‘xy’}
[1, 2, 4, 5, ‘xy’]

Posted under Python

Answer: (b).{1, 2, 4, 5, ‘xy’}
[1, 2, 4, 5, 2, ‘xy’, 4]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the code shown below?

Similar Questions

Discover Related MCQs

Q. Which of the following functions cannot be used on heterogeneous sets?

Q. Write a list comprehension for number and its cube for:

l=[1, 2, 3, 4, 5, 6, 7, 8, 9]

Q. Input order is preserved in sets. State whether this statement is true or false.

Q. Which of the following lines of code will result in an error?

Q. Set makes use of __________
Dictionary makes use of ____________

Q. If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the function:

Q. The difference between the functions discard and remove is that:

Q. The ____________ function removes the first element of a set and the last element of a list.

Q. Which of the following functions will return the symmetric difference between two sets, x and y?

Q. Set members must not be hashable. True or False?

Q. Which of these about a frozenset is not true?

Q. If a={5,6,7}, what happens when a.add(5) is executed?

Q. If a={5,6,7,8}, which of the following statements is false?

Q. Which of the following statements is used to create an empty set?

Q. Which of the following is not the correct syntax for creating a set?

Q. Which of these about a set is not true?

Q. Tuples can’t be made keys of a dictionary. True or False?

Q. What type of data is: a=[(1,1),(2,4),(3,9)]?

Q. If a=(1,2,3,4), a[1:-1] is

Q. What is the data type of (1)?