Program Console Vignaankosh.com
Execution Panel
Console is empty.
Difference of two sets (A - B) 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.
# Difference of two sets (A - B)
A = {1, 2, 3, 4, 5, 6}
B = {4, 5, 6, 7, 8, 9}
print("Set A:", A)
print("Set B:", B)
# Method 1: - operator
difference = A - B
print(f"\nA - B: {difference}")
# Method 2: difference() method
diff_method = A.difference(B)
print(f"A.difference(B): {diff_method}")
# B - A (different result)
b_minus_a = B - A
print(f"B - A: {b_minus_a}")
# Method 3: difference_update (modifies in-place)
A_copy = A.copy()
A_copy.difference_update(B)
print(f"After difference_update: {A_copy}")