【学习笔记】Numpy Exercise 100

This blog post presents a collection of 50 challenging Numpy exercises, ranging from basic operations like creating null vectors and matrices to advanced tasks such as converting Cartesian to polar coordinates and finding closest values in arrays. Each exercise is rated by difficulty and provides a stepping stone for mastering Numpy in data manipulation and scientific computing." 139182172,9632540,Docker中安装JDK的详细步骤,"['docker', 'java', '容器', '运维']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Numpy Exercise 100

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

Import numpy as np

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

print(np.__version__)
print(np.config())

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

data = np.zeros(10)

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

print(np.info(np.add))

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

data = np.zeros(10)
data[5]=1

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

data = np.range(10,50)

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

data = np.range(10)
data[::-1]

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

data = np.arange(0,9).reshape((3,3))

9.Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆)

data = np.nonzero([1,2,0,0,4,0])

10.Create a 3x3 identity matrix (★☆☆)

data = np.eye(3)

11.Create a 3x3x3 array with random values (★☆☆)

data = np.random.random((3,3,3))

12.Create a 10x10 array with random values and find the minimum and maximum values (★☆☆)

data = np.random.random((10,10))
dataMin,dataMax = data.min(),data.max()

13.Create a random vector of size 30 and find the mean value (★☆☆)

data = np.random.random(30)
dataMean = data.mean()

14.Create a 2d array with 1 on the border and 0 inside (★☆☆)

data = np.ones((4,4))
dat
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值