Python sympy.binomial_coefficients_list()方法

Python sympy.binomial_coefficients_list()方法

sympy.binomial_coefficients_list()方法的帮助下,我们可以找到作为帕斯卡三角形的行的二项式系数。

语法: binomial_coefficients_list(n)

参数 :
n –它表示一个整数。

返回:返回一个二项式系数的列表,作为帕斯卡三角形的行数。

示例 #1:

# import binomial_coefficients_list() method from sympy
from sympy.ntheory import binomial_coefficients_list
  
n = 6
  
# Use binomial_coefficients_list() method 
binomial_coefficients_list_n = binomial_coefficients_list(n) 
      
print("{}th row of Pascal's Triangle = {} ".format(n, binomial_coefficients_list_n))

输出:

6th row of Pascal's Triangle = [1, 6, 15, 20, 15, 6, 1] 

示例 #2:

# import binomial_coefficients_list() method from sympy
from sympy.ntheory import binomial_coefficients_list
  
n = 9
  
# Use binomial_coefficients_list() method 
binomial_coefficients_list_n = binomial_coefficients_list(n) 
      
print("{}th row of Pascal's Triangle = {} ".format(n, binomial_coefficients_list_n))

输出:

9th row of Pascal's Triangle = [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]  

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程