Create a set and display elements Dry Run in PYTHON

Create a set and display elements 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.

Create a set and display elements Program Code

# Create a set using curly braces
fruits = {"Apple", "Banana", "Cherry", "Mango", "Orange"}
print("Set:", fruits)
print("Type:", type(fruits))

# Create set using set() constructor
numbers = set([1, 2, 3, 4, 5])
print("\nUsing set():", numbers)

# Duplicates are automatically removed
duplicate_set = {1, 2, 2, 3, 3, 3, 4}
print(f"\nWith duplicates: {duplicate_set}")

# Display elements using loop
print("\nSet elements:")
for item in fruits:
    print(f"  {item}")

View the complete Sets programs page.

Program Console Create a set and display elements Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.