Program Console Vignaankosh.com
Execution Panel
Console is empty.
Count unique elements in collection 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.
# Count unique elements in various collections
# List
list_data = [1, 2, 2, 3, 3, 3, 4, 5, 5]
unique_count = len(set(list_data))
print(f"List: {list_data}")
print(f"Unique elements: {unique_count}")
# Tuple
tuple_data = (1, 1, 2, 2, 3, 4, 4, 5)
print(f"\nTuple: {tuple_data}")
print(f"Unique elements: {len(set(tuple_data))}")
# String
string_data = "programming"
print(f"\nString: '{string_data}'")
print(f"Unique characters: {len(set(string_data))}")
# Mixed data
mixed = [1, 'a', 2, 'a', 1, 'b', 3]
print(f"\nMixed: {mixed}")
print(f"Unique elements: {len(set(mixed))}")