human
Find all distinct subset ( or subsequence ) sums of an array | Uses Dynamic Programming to find distinct subset Sums.
dp [ i ] [ j ] would be true if arr [ 0. . i - 1 ] has a subset with Sum equal to j ..
There is always a subset with 0 Sum.
Fill dp [ ] [ ] in bottom up manner.
Sums that were achievable without current array element.
Print last row elements.
Driver code"
How can the above be solved in Python?

Can you provide a code to find all distinct subset ( or subsequence ) sums of an array and the other steps required?
assistant
#Here is code to find all distinct subset ( or subsequence ) sums of an array and the other steps required.
 def printDistSum ( arr , n ) :
	Sum = sum ( arr )
	dp = [ [ False for i in range ( Sum + 1 ) ] for i in range ( n + 1 ) ]
	for i in range ( n + 1 ) :
		dp [ i ] [ 0 ] = True
	for i in range ( 1 , n + 1 ) :
		dp [ i ] [ arr [ i - 1 ] ] = True
		for j in range ( 1 , Sum + 1 ) :
			if ( dp [ i - 1 ] [ j ] == True ) :
				dp [ i ] [ j ] = True
				dp [ i ] [ j + arr [ i - 1 ] ] = True
	for j in range ( Sum + 1 ) :
		if ( dp [ n ] [ j ] == True ) :
			print ( j , end = " ▁ " )
arr = [ 2 , 3 , 4 , 5 , 6 ]
n = len ( arr )
printDistSum ( arr , n )