Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the matrix multiplication between mat1 and mat2. If the two matrices are not compatible with multiplication, then None should be returned. (b) Write a function print_sums(list1, list2) that takes two equal-length lists of numbers and prints all the sums of the corresponding elements. Thus the first line is the sum of the first element of list1 and the first element of list2, the second line is the sum of the second elements, and so on.
Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the matrix multiplication between mat1 and mat2. If the two matrices are not compatible with multiplication, then None should be returned. (b) Write a function print_sums(list1, list2) that takes two equal-length lists of numbers and prints all the sums of the corresponding elements. Thus the first line is the sum of the first element of list1 and the first element of list2, the second line is the sum of the second elements, and so on.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
(a) Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the matrix multiplication between mat1 and mat2. If the two matrices are not compatible with multiplication, then None should be returned.
(b) Write a function print_sums(list1, list2) that takes two equal-length lists of numbers and prints all the sums of the corresponding elements. Thus the first line is the sum of the first element of list1 and the first element of list2, the second line is the sum of the second elements, and so on.
![Test
mat1 = np.array([[1, 2],
[3, 4]])
mat2
np.array([[4, 3],
[2, 1]])
print
(matrix_multiply(matl, mat2))
mat1 =
np.array([[1, 2, 3],
[4, 5, 6]])
mat2 = np.array([[6, 5, 4],
[3, 2, 1]])
print(matrix_multiply(mat1, mat2))
Result
[[85]
[20 13]]
None](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2f38207c-a65c-4294-8d77-eb45b88b09e4%2F935a9651-c272-44a4-823f-d6be7fd3d0e8%2Fyky4tm5_processed.png&w=3840&q=75)
Transcribed Image Text:Test
mat1 = np.array([[1, 2],
[3, 4]])
mat2
np.array([[4, 3],
[2, 1]])
print
(matrix_multiply(matl, mat2))
mat1 =
np.array([[1, 2, 3],
[4, 5, 6]])
mat2 = np.array([[6, 5, 4],
[3, 2, 1]])
print(matrix_multiply(mat1, mat2))
Result
[[85]
[20 13]]
None
![Test
Result
print_sums ([10, 20, 30], [1, 2, 3])
11
22
33
print_sums ([9, 3, 7, 1], [11, -1, 5, 1]) 20
2
12
2](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2f38207c-a65c-4294-8d77-eb45b88b09e4%2F935a9651-c272-44a4-823f-d6be7fd3d0e8%2Fgrustt9_processed.png&w=3840&q=75)
Transcribed Image Text:Test
Result
print_sums ([10, 20, 30], [1, 2, 3])
11
22
33
print_sums ([9, 3, 7, 1], [11, -1, 5, 1]) 20
2
12
2
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 6 steps with 6 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY