Generate all subsets (Power Set) Dry Run in PYTHON

Generate all subsets (Power Set) is an interactive PYTHON dry run visualizer from the Recursion 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.

Generate all subsets (Power Set) Program Code

def generate_subsets(s, idx=0, current=""):
    if idx == len(s):
        print(f"{{{current}}}")
        return
    generate_subsets(s, idx+1, current)
    generate_subsets(s, idx+1, current + s[idx])

print("All subsets of 'ABC':")
generate_subsets("ABC")

View the complete Recursion programs page.

Program Console Generate all subsets (Power Set) Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.