摘要:
点击查看代码 import numpy as np a = np.array([[0, 3, 4], [1, 6, 4]]) b = np.array([[1, 2, 3], [2, 1, 4]]) c = a / b #两个矩阵对应元素相除 d = np.array([2, 3, 2]) e = 阅读全文
摘要:
点击查看代码 import numpy as np a = np.arange(16).reshape(4,4) #生成4行4列的数组 b = np.floor(5*np.random.random((2, 4))) c = np.ceil(6*np.random.random((4, 2))) d 阅读全文
摘要:
点击查看代码 import numpy.random as nr x1=list(range(9,21)) nr.shuffle(x1) #shuffle()用来随机打乱顺序 x2=sorted(x1) #按照从小到大排序 x3=sorted(x1,reverse=True) #按照从大到小排序 x 阅读全文
摘要:
例2.15 加载模块示例 import math import random import numpy.random as nr a=math.gcd(12,21) b=random.randint(0,2) c=nr.randint(0,2,(4,3)) print(a);print(b);pri 阅读全文
摘要:
例2.13 数据分组 def bifurcate_by(L,fn): return [[x for x in L if fn(x)], [x for x in L if not fn(x)]] s = bifurcate_by(['beep','boop','foo','bar'],lambda x 阅读全文