Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Set basics
2. Defining sets
Relationships between sets
Summary

Instruction

All right, let's get started!

In their typical applications, sets store multiple values of the same type. What makes sets different from lists, dictionaries, and tuples? Sets can only contain unique values. For example, we have a set below called favorite_movies. Take a look at it:

favorite_movies = {'Halloween', 'A Star Is Born', 'Hocus Pocus'}

The code above creates a new set with three string elements. Note that we define a set by providing one or more elements inside curly braces. Dictionaries in Python also use curly braces, but they consist of key-value pairs, not individual values.

Exercise

The company XYC Corp. has recently opened a new branch. This branch currently has six employees:

  1. Christina Ball
  2. Santos Barnes
  3. Nancy Silva
  4. Lindsey Graham
  5. Heather Foster
  6. Katie Nguyen

Create a set named new_branch_employees containing all employees' names stored as string values.

Stuck? Here's a hint!

Remember to use single quotes around employees' names.