All problems
Scalar-Vector Multiplication
Problem
Multiply every component of vector v by the scalar s.
Return a new list w where w[i] = s * v[i].
Hint
A list comprehension over v is enough.
Test cases
case 1
in: [[1,2,3],2]
expected: [2,4,6]
case 2
in: [[1,-1,0],-3]
expected: [-3,3,0]
case 3
in: [[2.5,4],0.5]
expected: [1.25,2]
case 4
in: [[],5]
expected: []
Starter codePython
def scale_vector(v, s):
# Your code here
pass4 test cases · run your code against them in the editor