Python and Jupyter Notebooks
Python版本: Python3.x
Jupyter: 既可以写代码,也可以将代码生成文档。安装及使用教程请移步 https://www.cnblogs.com/rookieveteran/p/13356264.html
Python常用数据结构
- tuple
- list
- dict
tuple和list的区别: list可以修改, tuple不可以
用到的Python包
- numpy: 进行数学运算
- matplotlib: 画图
- networkx: 图论
- qiskit: 量子计算
- random: 随机数
引入numpy包的两种用法:
import numpy as np
np.sin( np.pi/2 )
from numpy import *
sin( pi/2 )
random包的用法
import random
a_list = [42, 0.5, True, [0, 1], None, 'apple', 3.14, 'sausages']
for j in range(5):
print('* Results from sample',j+1)
print('
Random number from 0 to 1:', random.random() ) # 从[0,1]中随机选取一个实数
print("
Random choice from our list:", random.choice( a_list ) ) # 从a_list中随机选取一个元素
print('
')
其他包的具体用法可在 https://pypi.org/search/ 查找其相应说明文档