Question

216#Question 5 - Bonus 217 def matrixMultiplication (matrix, vector): 218 219 220 221 Return the product of a matrix and a vector Arguments: matrix: A list of lists representing an nxn matrix vector: A list representing an nx1 matrix 223 224 225 226 227 228 229 230 231 232 233 234 Returns A list representing the nx1 matrix obtained by multiplying the input matrix by the input vector. >>> matrix = [[1, 2, 3], [2, 3, 1], [4, 1, >>> vector=[1, 2, 3] >>> matrixMultiplication (matrix, vector) [14, 11, 11] 2]] return False

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python Code:

def matrixMultiplication(matrix, vector):

               mv = []

               for l in matrix:

                              val = 0

                              for i in range(len(l)):

                                             val += l[i]*vector[i]

                              mv.append(val)

               return mv

Add a comment
Know the answer?
Add Answer to:
216#Question 5 - Bonus 217 def matrixMultiplication (matrix, vector): 218 219 220 221 """Return the product...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python def matrixMultiplication(matrix, vector):     """Return the product of a matrix and a vector    ...

    in python def matrixMultiplication(matrix, vector):     """Return the product of a matrix and a vector     Arguments:         matrix: A list of lists representing an nxn matrix         vector: A list representing an nx1 matrix     Returns:         A list representing the nx1 matrix obtained by multiplying the input         matrix by the input vector.     >>> matrix = [[1, 2, 3], [2, 3, 1], [4, 1, 2]]     >>> vector = [1, 2, 3]     >>> matrixMultiplication(matrix, vector)    ...

  • Fall spring 223 231 218 226 234 220 226 225 219 231 229 220 238 229...

    Fall spring 223 231 218 226 234 220 226 225 219 231 229 220 238 229 223 241 223 226 214 220 219 231 230 216 230 226 225 230 227 220 219 229 228 239 225 223 222 228 223 222 225 223 221 232 218 226 226 233 215 226 There is an attached Excel spreadsheet (DA5.xlsx) containing MAP scores for the Fall and Spring testing periods. Use the data and the power of Excel to compute the...

  • question 20 214 215 216 217 Use the following information to answer questions 20-23: Uzbekistan produces...

    question 20 214 215 216 217 Use the following information to answer questions 20-23: Uzbekistan produces two goods, computers and aircrafts. In the following table different feasible production combinations are given for Uzbekistan 218 219 Maximum annual Quantity of output options computers 220 221 222 Quantity of aircrafts 1,000 800 600 8.000 12,000 15,000 17,000 18,000 400 224 200 225 226 228 231 232 234 235 36 38 24 Computer 44 20 If Uzbekistan is currently producing at option B,...

  • 7. #4. 18 Following is a recursive function which takes as input (argument) a vector $x$...

    7. #4. 18 Following is a recursive function which takes as input (argument) a vector $x$ and returns a scalar. Either by looking carefully at the function, or by running the function with a few simple input vectors and observing the returned values in each case, determine what the function is doing. 29 00- "**{r} 01 - myfun=function(x){ 02 - if(length(x)=-1){return(x) C03 - } else 84 return(x[1]+my funcx[-1])) 205 - ) 206 myfun(c(1:1000)) #here's what happens when it is applied...

  • Download the hypothesis testing dataset from the class website. 1. This is case 1, in which...

    Download the hypothesis testing dataset from the class website. 1. This is case 1, in which the value of population standard deviation is assumed to be known. a. Compute the standard deviation of the textbook price and assume this to be the population standard deviation. Type this value in E5. b. Pick a random sample of size 15. c. Compute the mean of your random sample in E4 using the AVERAGE function. d. Calculate the standard error in cell E9...

  • Partial payments are made on the dates indicated. Use the United States rule to determine the...

    Partial payments are made on the dates indicated. Use the United States rule to determine the balance due on the note at the date of maturity. (The Effective Date is the date the note was written.) Assume the year is not a leap year. Effective Partial Payment Maturity Principal Date Amount Date Date $1900 19% Sept. 1 $500 Oct. 1 Dec. 1 $500 Nov. 1 Click the icon to view a table of the number of the day of the...

  • A partial payment is made on the date indicated. Use the United States rule to determine...

    A partial payment is made on the date indicated. Use the United States rule to determine the balance due on the note at the date of maturity. (The Effective Date is the date the note was written.) Assume the year is not a leap year. Effective Partial Payment Maturity Principal Rate Date Amount Date Date $4000 4% April 1 $1000 May 1 June 1 Click the icon to view a table of the number of the day of the year...

  • Question A matrix of dimensions m × n (an m-by-n matrix) is an ordered collection of m × n elemen...

    Question A matrix of dimensions m × n (an m-by-n matrix) is an ordered collection of m × n elements. which are called eernents (or components). The elements of an (m × n)-dimensional matrix A are denoted as a,, where 1im and1 S, symbolically, written as, A-a(1,1) S (i.j) S(m, ). Written in the familiar notation: 01,1 am Gm,n A3×3matrix The horizontal and vertical lines of entries in a matrix are called rows and columns, respectively A matrix with the...

  • Bubba's Burgers - Statistics Question

    Sampled StoreDessert Orders Per 1,000 TransactionsStore 1185Store 2226Store 3290Store 4226Store 5255Store 6293Store 7138Store 8203Store 9276Store 10173Store 11275Store 12199Store 13213Store 14321Store 1597Store 16152Store 17319Store 18193Store 19126Store 20215Store 21186Store 22289Store 23181Store 24196Store 25183Store 2690Store 27178Store 28103Store 29173Store 30231Store 31158Store 32202Store 33234Store 34273Store 35218Store 36247Store 37223Store 38108Store 39238Store 40143Store 41206Store 42300Store 4389Store 44202Store 45250Store 46210Store 47137Store 48215Store 49204Store 50188Store 51255Store 52196Store 53123Store 54189Store 55206Store 56146Store 57136Store 58211Store 59164Store 60246Store 61324Store 62125Store 63195Store 64173Store 65179Store 6676Store 67248Store 68199Store 69223Store 70240Store 71224Store 72215Store 73222Store 74170Store...

  • 33 On May 6, Jim Ryan borrowed $14,000 from Lane Bank at 7 % interest. Jim...

    33 On May 6, Jim Ryan borrowed $14,000 from Lane Bank at 7 % interest. Jim plans to repay the loan on March 11. Assume the loan is on ordinary interest. How much will Jim repay on March 11? (Use Days in a year table) (Round your answer to the nearest cent.) Jm repay etbook 7-1 TABLE Exact days-in-a-year calendar (excluding leap year)" Day of month 30 31 30 31 28 31 30 31 31 30 31 31 Dec Mar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT