JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

aiml | JustPaste.app
4 days ago1 views
👨‍💻Programming

aiml

def addition(A,B):
    result=[]

    for i in range(len(A)):
        row=[]
        for j in range(len(A[0])):
            row.append(A[i][j] + B[i][j])
        result.append(row)
    return result

def subtraction(A,B):
    result=[]

    for i in range(len(A)):
        row=[]
        for j in range(len(A[0])):
            row.append(A[i][j]-B[i][j])
        result.append(row)
    return result

def transpose(A):
    result=[]

    for j in range(len(A[0])):
        row=[]
        for i in range(len(A)):
            row.append(A[i][j])
        result.append(row)
    return result

rows=int(input("Enter rows of matrix: "))
cols=int(input("Enter columns of matrix: "))
A=[]
B=[]

print("Enter the first matrix: ")
for i in range(rows):
    row=[]
    for j in range(cols):
        x=int(input("Enter the element: "));
        row.append(x)
    A.append(row)

print("Enter the second matrix: ")
for i in range(rows):
    row=[]
    for j in range(cols):
        x=int(input("Enter the element: "));
        row.append(x)
    B.append(row)

print("Addition:", addition(A, B))
print("Subtraction:", subtraction(A, B))
print("Transpose of A:", transpose(A))
← Back to timeline