python数组乘以常数(python数组中一个元素乘二)
http://www.itjxue.com 2023-04-07 20:19 来源:未知 点击次数:
python数组乘以常数
给x0数组每个元素都乘以十的负三次方:
x0=[10,30,50,70,90,110,130,150,170,190,210,230,250,270,290,310,330,350,370,390,410,430,450,470,490]
x=[i*1e-3foriinx0]#十的负三次方不能表示为e-3。
结果如下:
[0.01,0.03,0.05,0.07,0.09,0.11,0.13,0.15,0.17,0.19,0.21,0.23,0.25,0.27,0.29,0.31,0.33,0.35000000000000003,0.37,0.39,0.41000000000000003,0.43,0.45,0.47000000000000003,0.49]。
python中如何用for语句计算数组的乘积
您好,您提问的问题有些模糊,如果问的是一维数组所有元素的成绩是这样的:
a?=?[1,2,3,4,5,6]???#Python中数组存放在list中
result?=?1???????#?result存放结果
for?i?in?a:
????result?=?i*result??#?a中每个元素都乘进result中
print?result
如果不是这个问题,请你将问题描述完善一些。
python numpy.array()后乘以数字是什么意思
array里每项都乘以这个数字,跟矩阵的操作差不多
例如
In [1]: import numpy
In [2]: a = numpy.array([1,2,3,4])
In [3]: b = a*2
In [4]: b
Out[4]: array([2, 4, 6, 8])