Post

Python Developer
Python Developer@PythonDvz·
What will be the output?? Comment down your answers in comment section.👨🏻‍💻👨🏻‍💻
Python Developer tweet media
English
12
3
19
3.2K
Salvo Micciché
Salvo Micciché@salvomic·
@PythonDvz Error: with set is permitted only the method union() otherwise | operator, not the sum with + set_sum = set1 | set2 set_sum = set.union(set2)
English
0
0
1
76
Balogun David 🫆
Balogun David 🫆@TheRareEngineer·
@PythonDvz Set1 = {1,2,3} Set2= {4,5,3,2} Print( len(Set1 + Set2)) Set1 + Set2 = {1,2,3,4,5} [Sets doesn'tacceptduplicate] len(Set1 + Set2) = 5 Therefore; Print( len(Set1 + Set2)) = 5 Option a
English
0
0
3
88
Harish
Harish@tweet_harry00·
@PythonDvz No duplicates in Set. So merge of 2 sets would lead to holding 1,2,3,4,5 Option A
English
0
0
1
64
Maxime LEONARD
Maxime LEONARD@MaxDotNet7335·
@PythonDvz Error: TypeError: unsupported operand type(s) for +: 'set' and 'set' d.Error I admit, I wrote the Python script.
English
0
0
0
49
Fullstack Tester
Fullstack Tester@TesterFullstack·
@PythonDvz Option d. Error is the correct answer. You can not use '+' operator to concatenate two sets, instead of '+' operator you use union() method or '|'. So, correct code should be either print(len(set_1 | set_2)) or print(len(set_1.union(set_2))) both return 5.
English
0
0
0
26
Paylaş