r/PythonLearning • • Oct 31 '26

Discussion What will be the output of the following Python code?

print(sum({1, 2, 2, 3} & {2, 3, 4}))

0 Upvotes

11 comments sorted by

4

u/recentAd1666 Oct 31 '26

What s the point of this question ? Just type the code in python. If you have more spécific question please ask it clearly.

2

u/Sea-Ad7805 Oct 31 '26

The point is to test if you know your set operators, so answer without first running the code, you might learn things.

4

u/recentAd1666 Oct 31 '26 edited Oct 31 '26

Oh it s a quizz ? I though it was a question. It is taggee discussion but there is nothing to discuss here. His there a quizz tag ? That would be better to understand what op intended here

-1

u/Sea-Ad7805 Oct 31 '26

Yes, I agree.

1

u/Makakhan Nov 01 '26

Yeah no, a complete waste of time. Run the code, see the answer, if you don’t understand why you got the answer look more into it.

0

u/Sea-Ad7805 Nov 01 '26

Then what's the "waste of time" part?

2

u/Sea-Ad7805 Oct 31 '26

5

1

u/Makakhan Nov 01 '26

These are the kinds of questions my fellow professors and teachers think are funny to put on tests and see if the can trick their students. Great job answering it tho!

2

u/Sea-Ad7805 Nov 01 '26

All those professors and teachers that want you to understand what is really going on when code runs, so annoying.

1

u/Key_River7180 29d ago

This seems like homework for me, type it to Python

0

u/DanceHackRock Oct 31 '26

It needs 5 seconds to try this.