(1)使用numpy中的arange函数来创建三个包含1~10的整数的numpy数组,使三个数组的形状分别为 10∗110∗1,2∗52∗5,5∗25∗2。
import numpy as np
a = np.arange(1,11)
b = np.arange(1,11)
c = np.arange(1,11)
a1 = a.reshape(1,10)
b1 = a.reshape(5,2)
c1 = a.reshape(2,5)
print ("数组10*1:")
print (a1)
print ("数组2*5:")
print (b1)
print ("数组5*2:")
print (c1)
(2)对生成的数组做exp、exp2、sqrt、sin、log函数运算。
print("exp() is:", "\n", "exp(a) is", "\n", np.exp(a), "\n", "exp(b) is", "\n", np.exp(b), "\n", "exp(c) is", "\n", np.exp(c))
print("exp2() is:", "\n", "exp2(a) is", "\n", np.exp2(a), "\n", "exp2(b) is", "\n", np.exp2(b), "\n", "exp2(c) is", "\n", np.exp2(c))
print("sqrt() is:", "\n", "sqrt(a) is", "\n", np.sqrt(a), "\n", "sqrt(b) is", "\n", np.sqrt(b), "\n", "sqrt(c) is", "\n", np.sqrt(c))
print("sin() is:", "\n", "sin(a) is", "\n", np.sin(a), "\n", "sin(b) is", "\n", np.sin(b), "\n", "sin(c) is", "\n", np.sin(c))
print("log() is:", "\n", "log(a) is", "\n", np.log(a), "\n", "log(b) is", "\n", np.log(b), "\n", "exp(c) is", "\n", np.log(c))