借助sympy.binomial_coefficients_list()方法,我們可以找到二項式係數作為Pascal三角形的行。
用法: binomial_coefficients_list(n)
參數:
n – 它表示一個整數。
返回值:返回二項式係數列表,作為Pascal三角形的行。
示例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 next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python os.abort()用法及代碼示例
- Python os.WEXITSTATUS()用法及代碼示例
- Python os.fchmod()用法及代碼示例
- Python PIL getpixel()用法及代碼示例
- Python PIL putpixel()用法及代碼示例
- Python os.sysconf()用法及代碼示例
- Python os.confstr()用法及代碼示例
- Python os._exit()用法及代碼示例
- Python cmath.log()用法及代碼示例
- Python Tensorflow cos()用法及代碼示例
- Python sympy.rf()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python | sympy.binomial_coefficients_list() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。