Program Console Vignaankosh.com
Execution Panel
Console is empty.
Find common elements between two sets is an interactive PYTHON dry run visualizer from the Sets programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
# Find common elements between two sets
set_a = {1, 2, 3, 4, 5, 6, 7}
set_b = {5, 6, 7, 8, 9, 10}
print("Set A:", set_a)
print("Set B:", set_b)
# Method 1: Using intersection operator &
common = set_a & set_b
print(f"\nCommon elements (&): {common}")
# Method 2: Using intersection() method
common2 = set_a.intersection(set_b)
print(f"Using intersection(): {common2}")
# Method 3: Manual loop
common3 = set()
for item in set_a:
if item in set_b:
common3.add(item)
print(f"Manual loop: {common3}")