0
0
Pythonprogramming~15 mins

Set creation in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Set creation
๐Ÿ“– Scenario: You are organizing a small event and want to keep track of unique guests who have RSVP'd. You will use a set to store the names of guests because sets automatically avoid duplicates.
๐ŸŽฏ Goal: Create a set of guest names, add a few names, and then display the set to see the unique guests.
๐Ÿ“‹ What You'll Learn
Create a set called guests with the names 'Alice', 'Bob', and 'Charlie'.
Create a variable called new_guest and set it to 'Alice'.
Add the new_guest to the guests set.
Print the guests set to show all unique guest names.
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Sets are useful to keep track of unique items like guest lists, product IDs, or tags without duplicates.
๐Ÿ’ผ Career
Understanding sets helps in data cleaning, filtering unique values, and optimizing searches in many programming jobs.
Progress0 / 4 steps
1
Create the initial set of guests
Create a set called guests with these exact names: 'Alice', 'Bob', and 'Charlie'.
Python
Need a hint?

Use curly braces {} to create a set with the names inside separated by commas.

2
Add a new guest variable
Create a variable called new_guest and set it to the string 'Alice'.
Python
Need a hint?

Use = to assign the string 'Alice' to the variable new_guest.

3
Add the new guest to the set
Add the guest stored in new_guest to the guests set using the add() method.
Python
Need a hint?

Use guests.add(new_guest) to add the new guest to the set.

4
Display the unique guests
Print the guests set to show all unique guest names.
Python
Need a hint?

Use print(guests) to display the set. The order may vary but the names should be unique.