multiplication

How to perform element-wise multiplication of two lists?

How to perform element-wise multiplication of two lists? Question: I want to perform an element wise multiplication, to multiply two lists together by value in Python, like we can do it in Matlab. This is how I would do it in Matlab. a = [1,2,3,4] b = [2,3,4,5] a .* b = [2, 6, 12, …

Total answers: 15

How to multiply individual elements of a list with a number?

How to multiply individual elements of a list with a number? Question: S = [22, 33, 45.6, 21.6, 51.8] P = 2.45 Here S is an array How will I multiply this and get the value? SP = [53.9, 80.85, 111.72, 52.92, 126.91] Asked By: bharath || Source Answers: You can use built-in map function: …

Total answers: 4

Python array multiply

Python array multiply Question: hh=[[82.5], [168.5]] N=1./5 ll=N*hh What I’m doing wrong? I received error : “can’t multiply sequence by non-int of type ‘float’” I try to add float(), but this is not solve my problem; I need to multiply each element in array… thanks to all **Ok thanks for idea for number * array, …

Total answers: 3

Create list of single item repeated N times

Create list of single item repeated N times Question: I want to create a series of lists, all of varying lengths. Each list will contain the same element e, repeated n times (where n = length of the list). How do I create the lists, without using a list comprehension [e for number in xrange(n)] …

Total answers: 9