3 The size of a set

Every set has a size: how many members it contains. If a set has been stored in Python, you can find its size using len. For example, here is a set of numbers:

nums = {6, 3, 5, 1, 7, 9, 11, 4}

If you enter this into the Python shell below and then execute

>>> len(nums)

you should get 8.

Euler diagrams are useful for reasoning about the size of sets. For example, consider the set of 52 playing cards in a standard pack (also called a deck). Figure 11 shows two smaller sets – picture cards and hearts – are contained in the overall set of size 52.

Figure 13 Picture cards and Hearts are sets contained within overall pack

Picture cards are jacks, queens and kings, and there are 12 of these altogether, 3 per suit. There are 13 cards in each suit.

The shaded intersection in Figure 14 represents the picture cards that are also hearts. There are 3 of these.

Figure 14 Picture cards and Hearts are sets contained within overall pack. There are 3.

You can continue to explore this in the next activity.

Activity 3 Figure it out

Allow about 5 minutes

The shaded areas in the diagrams below represent, respectively:

  • picture cards that are not hearts
  • hearts that are not picture cards
  • cards that are neither hearts nor picture cards.
Figure 15 Solution to activity

Using a pen and paper, copy the original Euler diagram and fill in the numbers for each of these regions.

Discussion

Your Euler diagram with the numbers should look like this.

Figure 16 The intersection of Picture cards and Hearts contains 3 cards.