跳转至

Python 中的 SymPy | Subset.rank_词典学()

原文:https://www.geesforgeks.org/sympy-subset-rank_词典编纂-in-python/

subset.rank_dictionary():rank_dictionary()是一个 sympy Python 库函数,返回子集的字典排序。

语法: sympy.combinations.subset.subset.rank_dictionary graphic()

返回: 该子集的词典排名。

代码# 1:rank_dictionary()示例

# Python code explaining
# SymPy.Subset.rank_lexicographic()

# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset

# Using from 
# sympy.combinatorics.subset.Subsets.rank_lexicographic()

# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])

# rank_lexicographic value
print ("Subset a rank_lexicographic : ", a.rank_lexicographic)

输出:

子集 a 等级_字典顺序:14

代码# 2:rank_dictionary()示例

# Python code explaining
# SymPy.Subset.rank_lexicographic()

# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset

# Using from 
# sympy.combinatorics.subset.Subsets.rank_lexicographic()

# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])

# rank_lexicographic value
print ("Subset a rank_lexicographic : ", a.rank_lexicographic)

输出:

子集 a 等级_字典顺序:19



回到顶部