Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Python function powerSet() that takes in a finite list object A and returns P(A), the power set of A. The output should be
Write a Python function powerSet() that takes in a finite list object A and returns P(A), the power set of A. The output should be only in the form of list objects. Note: Make sure you are familiar with some of Python's basic built-in list functions and operators, as they will make completing this problem far easier. For example: Test A = [0, 1, 2] output = set([frozenset(a) for a in power Set(A)]) expected = [[], [0], [0, 1], [2], [1], [0, 2], [1, 2], [0, 1, 2]] expected = set([frozenset(a) for a in expected]) print (output=rexpected) A = ['a', 'b', 'c', 'd'] output = set([frozenset(a) for a in powerSet(A)]) expected = [[], ['a'], ['b'], ['a', 'b'], ['c'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c'], ['d'], ['a', 'd'], [ expected = set([frozenset(a) for a in expected]) print (output==expected)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started