SymPy | Subset.subset() in Python

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

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

Return :
the subset represented by the current instance.

Code #1 : subset() Example

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :



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

Code #2 : subset() Example

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

Subset a subset : [2, 3, 4]

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.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.