Skip to content
Related Articles

Related Articles

Improve Article

SymPy | Subset.subset() in Python

  • Last Updated : 28 Aug, 2019

Subset.subset() : subset() is a sympy Python library function that returns the subset represented by the current instance.

Syntax :
sympy.combinatorics.subset.Subset.subset()

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Return :
the subset represented by the current instance.



Code #1 : subset() Example




# Python code explaining
# SymPy.Subset.subset()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.subset()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# subset value
print ("Subset a subset : ", a.subset)

Output :

Subset a subset : [‘c’, ‘d’]

Code #2 : subset() Example




# Python code explaining
# SymPy.Subset.subset()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.subset()
  
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
  
# subset value
print ("Subset a subset : ", a.subset)

Output :

Subset a subset : [2, 3, 4]




My Personal Notes arrow_drop_up
Recommended Articles
Page :