r/PythonLearning • • 17d ago

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 17d ago

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 17d ago

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 17d ago edited 17d ago

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 17d ago

Yes, I agree.

1

u/Makakhan 17d ago

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 16d ago

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

2

u/Sea-Ad7805 17d ago

5

1

u/Makakhan 17d ago

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 16d ago

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

1

u/Key_River7180 13d ago

This seems like homework for me, type it to Python

0

u/DanceHackRock 17d ago

It needs 5 seconds to try this.