0
0
Pythonprogramming~15 mins

Difference and symmetric difference in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Difference and symmetric difference
๐Ÿ“– Scenario: You are organizing two groups of friends who like different sports. You want to find out who likes only one sport and who likes both.
๐ŸŽฏ Goal: Build a program that finds the difference and symmetric difference between two sets of friends.
๐Ÿ“‹ What You'll Learn
Create two sets with exact friend names
Create a variable for the difference of the two sets
Create a variable for the symmetric difference of the two sets
Print the results exactly as instructed
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Finding differences and unique members between groups is useful in event planning, marketing, and social networks.
๐Ÿ’ผ Career
Understanding set operations helps in data analysis, database queries, and software development tasks involving collections.
Progress0 / 4 steps
1
Create two sets of friends
Create a set called basketball_fans with these exact names: 'Alice', 'Bob', 'Charlie'. Then create another set called soccer_fans with these exact names: 'Bob', 'David', 'Eve'.
Python
Need a hint?

Use curly braces {} to create sets and separate names with commas.

2
Create difference variable
Create a variable called only_basketball that holds the difference between basketball_fans and soccer_fans using the - operator.
Python
Need a hint?

Use the minus sign - between the two sets to get the difference.

3
Create symmetric difference variable
Create a variable called either_but_not_both that holds the symmetric difference between basketball_fans and soccer_fans using the ^ operator.
Python
Need a hint?

Use the caret ^ operator to find the symmetric difference.

4
Print the results
Print the variables only_basketball and either_but_not_both exactly as shown: print("Only basketball fans:", only_basketball) and print("Fans of either sport but not both:", either_but_not_both).
Python
Need a hint?

Use two print statements with the exact text and variables.