The sum of the matrices is obtained using the for loop, using nested list comprehension, and by using the zip().
Source Code for finding the sum of the matrices using the zip():
The zip() function takes an iterator for each matrix element, maps them, and then adds them using the sum() function. It returns the result and saves it in the mapping form.
X = [[1,2,3],
    [4 ,0,6],
    [7 ,8,9]]
Y = [[9,4, 7],
    [6,5,2],
    [3,2,6]]
result1= [map(sum, zip(*t)) for t in zip(X, Y)]
  print(result)
Related Questions
- How do you add to a matrix in python?
- How do you make a vowel counter in Python?
- How do I remove punctuation from a list in Python?
- How do you transpose a matrix in python?
- How do you count the number of vowels in a list in Python?
- How do I remove punctuation from a text file in Python?
- How do you transpose in Python?
- How do you extract a vowel from a string in Python?
- How do you remove special and punctuation characters in Python?
- How do you add two matrices in Python using Numpy?
- Is vowel function in Python?
- How do I remove special characters from a list in Python?
- How do you transpose amatrix using Numpy in Python?
Leave a Reply