Question

Write a program to multiply two matrices using array.

07 Aug 2023
Answer :
Word Count : 601

Here's a Python program that multiplies two matrices using arrays (lists of lists):

def matrix_multiplication(matrix1, matrix2):
    rows1 = len(matrix1)
    cols1 = len(matrix1[0])
    rows2 = len(matrix2)
    cols2 = len(matrix2[0])

    if cols1 != rows2:
        print("Matrix multiplication not possible.")
        return None

    result = [[0 for _ in range(cols2)] for _ in range(rows1)]

    for i in range(rows1):
        for j in range(cols2):
            for k in range(cols1):
                result[i][j] += matrix1[i][k] * matrix2[k][j]

    return result

# Main program
if __name__ == "__main__":
    try:
        rows1 = int(input("Enter the number of rows for matrix 1: "))
        cols1 = int(input("Enter the

________ __________ _________ ___ _____ _________ _____ ____ _______.
______ _______ ___ ___ ______ ___ _______ _______ ______ _________ _____ ________.
___ ______ _____ ______ _____ __________ ___ ________ __________.
_____ _____ ____ ____ _________ ___ _________.
_____ ______ _______ _______ _____ _______ _________ ________.
___ _____ ___ ________ ________ ____ _____ ______ ___ _______ __________.
______ ____ _____ ________ _________ _________ ___ _______ ________.
_________ __________ ____ _____ _____ ____ ___ ____ ________ _______.
_____ _________ ______ _________ ____.
_____ _________ __________ ______ ____ _______ _______.
______ ___ _________ _________ _____ _______ ______ __________ ____ _______ _____.
____ _________ ________ ____ __________ _______ __________ _______ _____.
______ _________ _______ ________ _________ _______ ___ ___.
_____ ____ _________ __________ ______ ________ ___ __________ _____.
___ ____ ______ _________ _________ ___ ________ _______ ___ ____ ________ ___.
_______ ____ __________ ___ ____ ____ _____ _______ _______.
________ _____ __________ ____ ______ ____ _____ _______.
___ _________ ____ ______ ___.
________ ________ ______ ____ ____ ______ _______ _________ ___ ________.
_________ ____ ___ ______ _______.
_______ ________ _______ ________ ________ _________ ____ ________ ____ ________ ____ _________.
____ ___ ________ _________ ______ _________ _________ ____ ________ ____.
___ ____ _____ ________ ___ _________ ___ _________ ______.
______ _______ __________ ___ __________ ________ _________ _____ ___ ___ __________.
____ ______ ____ _______ _______.
________ ____ __________ _____ ______ ____ _____ ________ ______ ___ ______ _________.
____ ________ ___ ______ ________ __________.
__________ ____ __________ _________ _____ ____.
_____ _________ _____ _______ ______ _____.
__________ ___ _______ ___ _______ _________ ____ ___ ________ ________ _____.
____ __________ ____ _______ _____ _______.
______ ____ ___ ___ ______ _______ ____ ______ ____ _______ _____ __________.
_____ _____ ____ ______ _____ ________ ___ _____ _______ _________.
___ _______ ___ ________ ________ _______ __________ ___ ____ _____ ____.
_________ _________ ___ ___ _______ _____ ___ _________ ______.
_________ _______ _____ _______ ________ ______ ________ _______.
_________ _______ ________ _______ ___ _______ ______ ________ ________ _________.
______ _______ _____ ___ ___ ___ _______ _______ ___ ______.
____ _______ ______ __________ ________ _______ _________ __________ _________ _______ _________.
__________ ______ ______ __________ __________ __________ __________ _____.
___ ______ _____ _________ ___ ___ ______ __________ ________ __________ _______.
__________ _____ ____ __________ _______ _____ __________ ___ ________ _________ ___ __________.
_________ ________ _____ __________ ___ _________ ______ __________ ______ ___ __________ ______.
__________ __________ ________ _______ ________ __________ __________ ____ ____ _____ ___ _____.
________ _____ _____ _______ _________ ________ ________ ____.
_________ ____ __________ _____ ___ _____ ____ ______ ____ ____ ____ ________.
________ _______ _____ ___ _______.
____ ___ _________ __________ ______ _________ ___ ___.
________ ______ ____ ________ _______ _____ ______ ______ _________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCSL 33 2023 2024 - Write a program to multiply two matrices using array. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→