Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
21
11
141
12.6K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: A) True The set trap that catches beginners! › y = {1, 3, 2, 3} → {1, 2, 3} (set elements are unique) › Sets ignore order › x and y both contain {1, 2, 3} › x == y → True For beginners: Sets are unordered collections with unique elements. It's like dictionaries, but without values.
English
0
0
0
595
Omo Yewa
Omo Yewa@AceKelm·
@PythonPr Answer: A. True They are both of a set data type. And sets don't allow duplicate values. Therefore, the repetition of 3 in set y will be ignored while testing for the condition. So that makes x==y to be true. Because they contain the same in numbers of unique values.
English
0
0
0
472
Slinxs
Slinxs@JSlinxsx·
@PythonPr Correct Answer: ✅ (A) True Why?: Sets ignore duplicate and order, so {1, 2, 3} and {1, 3, 2, 3} are considered equal.
English
0
0
0
270
Sudarshan Bankar
Sudarshan Bankar@bankarsudarxhan·
@PythonPr True because sets don't store duplicate values So, x and y both essentially store {1, 2, 3}
English
0
0
0
20
Gk
Gk@Gk54259045·
@PythonPr A) True Why Because x and y are sets. Duplicate are automatically ignored
English
0
0
0
337
Tanmoy🇮🇳
Tanmoy🇮🇳@i_m_tc·
@PythonPr It should be true because Y has a duplicate element in this set. So X & Y are the same. If X==Y is the question, it has to be true.
English
0
0
0
237
Biel Men
Biel Men@BielMenHaha·
@PythonPr Yeah, I was wrong, set will remove the same elements and compare if they are the same in ASCII order. The statement "is" isn't being used, so it will only compare. So the return is the bool True
English
0
0
0
27
Paylaş