Unit: Unit 5: Dictionaries and Sets • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Compute the union of two skill sets
backend_skills = {"Python", "PostgreSQL", "Docker"}
frontend_skills = {"TypeScript", "React", "Docker"}
# 1. Union using the | operator
all_skills_op = backend_skills | frontend_skills
# 2. Union using the .union() method
all_skills_method = backend_skills.union(frontend_skills)
print("All unique skills (sorted):", sorted(all_skills_op))
print("Operator and method produce identical results:", all_skills_op == all_skills_method)
print("Total distinct skills:", len(all_skills_op))