Open In App
Related Articles

SymPy | Subset.rank_gray() in Python

Improve Article
Improve
Save Article
Save
Like Article
Like

Subset.rank_gray() : rank_gray() is a sympy Python library function that returns the Gray code ranking of the subset.

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

Return :
Gray code ranking of the subset

Code #1 : rank_gray() Example




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


Output :

Subset a rank_gray : 2

Code #2 : rank_gray() Example




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


Output :

Subset a rank_gray : 11


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 26 Aug, 2019
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials