安装和使用sympy

1、About SymPy:

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible 

in order to be comprehensible and easily extensible. SymPy is written entirely in Python.

2、下载sympy软件包:

到官方网站:http://www.sympy.org/en/index.html下载
安装和使用sympy_第1张图片

或者直接通过github下载:https://github.com/sympy/sympy/releases

选择:sympy-1.0.tar.gz,点击下载压缩文件:sympy-1.0.tar

3、解开压缩包,找到sympy包所在的文件夹,如图。

安装和使用sympy_第2张图片

4、在上面所示的文件夹内,打开命令行窗口,执行:pip install sympy
出现下图,导入包结束。
安装和使用sympy_第3张图片

5、示例:

import sympy
a,b = 500,600
print(a,b)
numbers = range(a,b)
prime_numbers = filter(sympy.isprime, numbers)
print("Prime numbers({}-{}:".format(a,b))
for prime_number in prime_numbers:
    print(prime_number,end=",")
print()

执行结果:
500 600
Prime numbers(500-600:
503,509,521,523,541,547,557,563,569,571,577,587,593,599,

Process finished with exit code 0




你可能感兴趣的:(Python)