栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

numpy练习

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

numpy练习

(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))

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/923291.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号