如何创建包含该数字及其平方的 1:100 数字数组?
该函数将返回 python 中的结果:
x1= np.array([[1,1],
[2,4],
[3,9],
[4,16],
[5,25]])
最佳答案
我更喜欢 arange
和 c_
:
nums = np.arange(1, 101)
np.c_[nums, nums ** 2]
关于python - 在python中返回一个数字及其平方的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69784645/