Numpy练习100题--难度★☆☆

1.Import the numpy package under the name np (★☆☆)

#导入numpy模块
import numpy as np

2.Print the numpy version and the configuration (★☆☆)

#打印numpy的版本信息
print np.version.version
print np.__version__
np.show_config()

3.Create a null vector of size 10 (★☆☆)

#新建全为0的数组
vector=np.zeros(10)#一维
vector_2=np.zeros((10,10))#二维

4.How to find the memory size of any array (★☆☆)

#数组所占内存大小=元素个数*每个元素的大小
print vector.size*vector.itemsize

5.How to get the documentation of the numpy add function from the command line? (★☆☆)

#命令行获取numpy的add函数的文档信息
python -c "import numpy;numpy.info(numpy.add)"

6.Create a null vector of size 10 but the fifth value which is 1 (★☆☆)

#创建非空的大小为10的数组,第5个元素为1
vector=np.zeros(10)
vector[4]=1

7.Create a vector with values ranging from 10 to 49 (★☆☆)

#创建一个数组,元素值从10-49
vector=np.arange(10,50)

8.Reverse a vector (first element becomes last) (★☆☆)

#翻转一个数组
vector[::-1]

9.Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆)

#创建一个3*3的矩阵,元素值为0-8
vector=np
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值