Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

Saturday, August 5, 2023

DETERMINANTS

r1=int(input("Enter row of first matrix less than 6 = "))

c1=int(input("Enter column of first matrix less than 6 = "))


if r1==c1:

    l=[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]

    p=[]

    y=0

    x=0

    

    for i in range(0,3):

        for j in range(0,3):

            x=int(input("Enter a number ="))

            l[i][j]=x

            

    for i in range(0,r1):

        for j in range(0,r1):

            print(l[i][j],end=' ')

        print()

    for i in range(0,r1):

        for j in range(0,r1):

            if j!=i and i!=2:

                x=l[1][j]*l[2][j+i+1]

                y=l[1][j+1+i]*l[2][j]

                if i%2==0:

                    p.append(l[0][i]*(x-y))

                else:

                    p.append(l[0][i]*(y-x))

            if j!=i and i==2 and j!=1:

                x=l[1][j]*l[2][j+i-1]

                y=l[1][j-1+i]*l[2][j]

                p.append(l[0][i]*(x-y))

        print()

    c=0

    for i in range(0,len(p)):

        c+=p[i]

    print("Determinants =",c)

OUTPUT