Python's sets do the counting of a Venn diagram for you. A class has the roll numbers to . The students whose roll number is even take mathematics; those whose roll number is a multiple of take physics.
The idea. & gives the intersection, | the union and - the difference of two sets.
Your tasks.
both to the students who take both subjects.neither to the number of students who take neither.only_maths to the students who take mathematics but not physics.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…