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: "))
    ___ ____ _______ ___ _______ _____ ___ ___ _____.
_______ ________ ______ _________ __________.
_____ __________ ___ _______ ____ _____ ___ _________.
_______ ____ ____ ___ ________ _____ ______ ____ ________ __________ ________ ______.
___ ___ _______ _____ ____ _____ _________ _______ _______ _____ _______.
_____ _________ ____ _____ ______ __________ ________ _____.
__________ ________ ________ _____ _________ __________ _____ ________.
_____ ____ ______ ______ _______ ___ ______ ____ ___.
______ _____ ____ ______ _________ ________ ____.
____ _________ ________ _________ ________ _______ ______ _____ _______ _________ ___ ________.
________ _______ ____ ______ _____ ______ _________ __________ ________ ___ _______.
__________ _______ ________ _________ ___ ______ ________ ______ _________ __________.
________ _______ __________ ________ _______ ____.
________ ________ ________ _________ _____ ______ __________ ________ ______.
_____ __________ ________ ____ __________ _______ ____.
________ ________ ________ ______ ________ _______ ______ __________ ___.
________ __________ ___ _________ ___ ______ ________.
__________ _________ ______ ______ _____ __________ _________ _________ _________ _____ ______ _________.
____ __________ ___ _____ ___ __________ ______.
______ _____ _____ _______ ___ _______ ____ ___ __________ ____ ____.
_________ ______ ______ ________ ______ ____ ______ __________ __________ _____ ______.
________ ____ _________ ____ __________ _____ ____ _______.
_____ ______ ______ ________ __________ ________ ______ _______ __________ __________ ________ ___.
______ _______ ____ ________ _______ _________ ___ ___ _______ ______ ________.
____ _____ _________ ______ _________ ___ _________ ______ ________ ________ _____.
____ _____ _______ ________ _________ ____ ______ ______ ____.
___ _________ _______ _______ ______ _______ _______ _________ _______.
___ ______ __________ ___ ______ _____ __________ ____ _____ ______ ________ ___.
______ _______ ____ _________ _____ ___.
________ _____ _______ _____ __________ ______.
_______ _____ _______ ______ ___.
____ ___ _____ ________ ________.
________ ___ _______ _______ _______ ________ ______ ___ _________ ________ ____ _____.
_______ ___ _____ ______ ______.
____ __________ ____ ______ ____ ____.
______ ___ __________ ___ _______ _________ __________ _____ ______ ___ _____.
_________ ____ __________ _____ _______ _____.
___ ________ ___ ______ _________ _______.
___ ______ ____ ________ _______ _________.
_________ _________ ________ ______ __________.
_____ __________ ______ ____ ________ ______ ___ ______ __________.
__________ _______ _____ _________ ____ __________ _______ ________ _________ _____ __________ ______.
__________ ___ ___ __________ _______.
______ ____ ______ ____ _____ ___ ________ ____ _____ ___ ___.
___ ________ ______ ______ ____ ________ _____ _______.
___ _______ ______ ___ _________ ___ _________.
____ ____ ___ _______ ______ __________.
_______ _________ ____ ______ ________ ____ ______ ______ ____ ____.
____ _______ _________ ________ _____ ______.
________ ________ __________ ______ ____ ________ __________ ______ ___ ____ _______.
___ __________ _________ __________ _____ ___ _____ ___ ________ _______ ______ ________.
________ _____ __________ ________ ____ ___.
______ ___ ____ ____ ___ _________ ____ ______.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Write a program to multiply two matrices using array.
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→