#31 Python Tutorial for Beginners | Working with Matrix in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ธ.ค. 2024

ความคิดเห็น • 726

  • @dipbhowmik4583
    @dipbhowmik4583 3 ปีที่แล้ว +47

    I have watched several python basic courses online. But none of them discussed array or specially multidimentional array using numpy in python. But this dude talked about each and every single topic from python. He is freaking awesome ! Seriously!! These things are specially added in premium courses of python may be! Anyway respect Sir. Highly appreciate your efforts .

  • @jayanthkumar5238
    @jayanthkumar5238 3 ปีที่แล้ว +181

    i am in final year. i will pay you the fees for this when i get my first salary of my first job. THANKS!

    • @mukulyadav9011
      @mukulyadav9011 3 ปีที่แล้ว +4

      Given are 2 similar dimensional numpy arrays, how to get a numpy array output in which every element is an element-wise sum of the 2 numpy arrays? pls help me with this

    • @madisettykeerthi8574
      @madisettykeerthi8574 2 ปีที่แล้ว +3

      @@mukulyadav9011 i guess, m3=m1+m2

    • @sr-ju4lq
      @sr-ju4lq 2 ปีที่แล้ว +1

      @@mukulyadav9011 it is shown in last video

    • @sharad3295
      @sharad3295 2 ปีที่แล้ว

      @@mukulyadav9011 or you can use for loop to do

    • @emna904
      @emna904 ปีที่แล้ว +1

      I wish all the best for you

  • @praanshugrover_98
    @praanshugrover_98 5 ปีที่แล้ว +21

    Code:
    from numpy import *
    print("Data for matrix 1")
    x = int(input("Enter the length of rows of array"))
    y = int(input("Enter the length of columns of array"))
    matrix1 = zeros([x, y], dtype=int)
    for i in range(x):
    a = array([])
    for j in range(y):
    element = int(input("Enter the element of array"))
    a = append(a, element)
    matrix1 = append(matrix1, [a], axis=0)
    for i in range(x):
    matrix1 = delete(matrix1, 0, 0)
    print("Entered matrix is: ")
    print(matrix1)
    print("Data for matrix 2")
    c = int(input("Enter the length of rows of array"))
    if y == c:
    d = int(input("Enter the length of columns of array"))
    matrix2 = zeros([c, d], dtype=int)
    for i in range(c):
    a = array([])
    for j in range(d):
    element = int(input("Enter the element of array"))
    a = append(a, element)
    matrix2 = append(matrix2, [a], axis=0)
    for i in range(c):
    matrix2 = delete(matrix2, 0, 0)
    print("Entered matrix is: ")
    print(matrix2)
    matrix3 = zeros([x, d], dtype=int)
    for i in range(x):
    for j in range(d):
    for k in range(c):
    matrix3[i][j] += matrix1[i][k] * matrix2[k][j]
    print("Matrix after multiplication: ")
    print(matrix3)
    else:
    print("Multiplication not possible as columns of matrix 1 is not equal to rows of matrix 2")
    Output:
    Data for matrix 1
    Enter the length of rows of array2
    Enter the length of columns of array3
    Enter the element of array1
    Enter the element of array2
    Enter the element of array3
    Enter the element of array4
    Enter the element of array5
    Enter the element of array6
    Entered matrix is:
    [[1. 2. 3.]
    [4. 5. 6.]]
    Data for matrix 2
    Enter the length of rows of array3
    Enter the length of columns of array2
    Enter the element of array7
    Enter the element of array8
    Enter the element of array9
    Enter the element of array10
    Enter the element of array11
    Enter the element of array12
    Entered matrix is:
    [[ 7. 8.]
    [ 9. 10.]
    [11. 12.]]
    Matrix after multiplication:
    [[ 58 64]
    [139 154]]

  • @ajeettharu1785
    @ajeettharu1785 4 ปีที่แล้ว +91

    You are the best teacher of python , i have ever seen sir ji .....feeling happy to watch your python series

    • @aniketatole2936
      @aniketatole2936 3 ปีที่แล้ว +1

      Yes!!

    • @mukulyadav9011
      @mukulyadav9011 3 ปีที่แล้ว +1

      Given are 2 similar dimensional numpy arrays, how to get a numpy array output in which every element is an element-wise sum of the 2 numpy arrays? pls help

    • @samgilchristv
      @samgilchristv 2 ปีที่แล้ว

      @@mukulyadav9011
      Take for Example One Dimensional Numpy Array
      -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      from numpy import *
      arr1 = array([1,4,3,7]) # 1st Array
      arr2 = array([5,3,8,1]) # 2nd Array
      arr3 = arr1 + arr2 # This will add element-wise as u said
      print(arr3)
      -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Output:-
      >>> [6 7 11 8]
      This is also Know as "Vectorised Operation"
      He Literally Mentioned about this in the Previous Video (#30) .See from 1:35

  • @yashsolanki3339
    @yashsolanki3339 4 ปีที่แล้ว +9

    Hi Navin Sir ! I'm yash from Ahmedabad
    I'm really enjoying the series of python in the condition of lockdown and I'm about to finish in some days,
    WHAT I WANT TO TELL YOU IS!
    please you also teach us Machine learning too !! I know there are lots of
    International institutes who teaches data science and machine learning but i had experience form one the institution and that was bad, and i realized they doing just job they actually not intrested to teach which I've noticed,
    NOW, WHEN IT COMES TO YOU.!
    It' seems like you're enthusiastic towards teaching us with lots of energies and fun and that's how we can learn, no matter we're not getting certificates here but what really important is KNOWLEDGE, and in the series of python i realized you're really a worth teacher to gain the knowledge
    So please I'm requesting you to teach us machine learning!
    And Thank you so much for sharing your KNOWLEDGE here !!
    Lots of love and wishes to you and your family ❤❤❤

  • @Siddharth-uo6zw
    @Siddharth-uo6zw 4 ปีที่แล้ว +16

    When I saw you I remember Mr.Satya Nadela I will pray to god and support you through donations and watching ads without skipping any ad so, that you will be able to make a huge IT Company in India you are fabulous sir.

  • @danielkamau8436
    @danielkamau8436 4 ปีที่แล้ว +8

    waoh!! what a good class about matrices, am a new learner with completely no knowledge of coding and learning this through personal initiative but I bet am growing in some good speed, courtesy of Navin. I pray GOD never to lack something for us your trainees

  • @RhoChalmers
    @RhoChalmers 3 ปีที่แล้ว +5

    OMG... you are so young in the matrix multiplication video. Thank you for these python & math videos!

  • @ameernexus
    @ameernexus 4 หลายเดือนก่อน

    I have watched several python basic courses online. But none of them discussed array or specially multidimentional array using numpy in python. But this dude talked about each and every single topic from python. He is freaking awesome ! Seriously!! These things are specially added in premium courses of python may be! Anyway respect Sir. Highly appreciate your efforts .

  • @vijaychauhan1590
    @vijaychauhan1590 3 ปีที่แล้ว +2

    Getting different results when typing below code
    from numpy import *
    m1=matrix('1 2')
    m2=matrix('3 4')
    m3=m1+m2;
    print(m3)
    Output :-
    C:\Users\chauhv1\PycharmProjects\pythonProject1\venv\Scripts\python.exe C:/Users/chauhv1/PycharmProjects/pythonProject1/venv/Scripts/numpy.py
    Traceback (most recent call last):
    File "C:\Users\chauhv1\PycharmProjects\pythonProject1\venv\Scripts
    umpy.py", line 1, in
    from numpy import *
    File "C:\Users\chauhv1\PycharmProjects\pythonProject1\venv\Scripts
    umpy.py", line 3, in
    m1=matrix('1 2;')
    NameError: name 'matrix' is not defined
    Process finished with exit code 1

    • @vijaychauhan1590
      @vijaychauhan1590 3 ปีที่แล้ว

      I tried reinstalling numpy that helped :)

    • @mantesh08
      @mantesh08 3 ปีที่แล้ว +1

      The same happened to me...
      Do u get any solution?

    • @vijaychauhan1590
      @vijaychauhan1590 3 ปีที่แล้ว +1

      @@mantesh08 reinstall numpy that will help

  • @raghavarora8422
    @raghavarora8422 2 ปีที่แล้ว +1

    You r the finest teacher of python as im from civil enginerring and got placed in It company...and the way u taught that made me pro in python

  • @ponnapallinagasindhu1922
    @ponnapallinagasindhu1922 5 หลายเดือนก่อน +1

    you mirrored your video at 8:31 to make us understand for diagnol elements.......WOW, SUCH A WONDERFUL TEACHER U R! 🙌

  • @saikumarpulicharla9483
    @saikumarpulicharla9483 5 ปีที่แล้ว +4

    Multiplication of two matrices m1 ( m * n ) and m2 ( n * o ) output m3 ( m * o)
    from numpy import *
    m1=matrix('1,2,3;2,3,4;5,6,7')
    m2=matrix('2;4;6')
    m3=zeros((len(m1[:,1]),len(m2.T)))
    if len(m1.T) != len(m2[:,0]):
    print('wrong dimensions')
    else:
    for i in range(len(m1[:, 1])):
    for j in range(len(m2.T)):
    a = array(m1[i, :])
    b = array(m2[:, j].T)
    m3[i, j] = sum(a * b)
    print(m3)

  • @054_ritesh3
    @054_ritesh3 4 ปีที่แล้ว +20

    Awesome teaching skills,
    You are one of the best teachers I have ever seen!!!! 👍👍👍

  • @yashjadhav3974
    @yashjadhav3974 4 ปีที่แล้ว +6

    arr2.reshape(2,2,3).........explanation: 2 array that contains 2 sub array of 3 element each

  • @mortezaoskuei9738
    @mortezaoskuei9738 5 ปีที่แล้ว +15

    from numpy import *
    arr1=array([
    [1,2,3],
    [4,5,6]])
    arr2=arr1.reshape(3,2)
    arr3=ones((2,2))
    for i in range(2):
    for j in range(2):
    c=0
    for k in range(3):
    f=arr1[i][k]*arr2[k][j]
    c=c+f
    arr3[i][j]=c
    print(arr3)

  • @boooringlearning
    @boooringlearning 3 ปีที่แล้ว +19

    you are indeed an excellent teacher of Python!

  • @macreenamachado4909
    @macreenamachado4909 3 ปีที่แล้ว +1

    import numpy as np
    m1 = np.matrix(np.arange(1,11).reshape((2,5)))
    m2 = np.matrix(np.arange(1,11).reshape((5,2)))
    m3 = np.matrix(np.zeros(4).reshape((2,2)), int)
    t1 = m1.shape
    t2 = m2.shape
    #if shape mismatch display error message
    if( t1[0] != t2[1] and t1[1] != t2[0]):
    print("multiplication cant be done")
    else:
    for i in range(t1[0]):
    for j in range(t2[1]):
    for k in range(t1[1]):
    m3[i,j] += m1[i, k] * m2[k, j]
    print(m3)
    print(m1 * m2)
    op:
    [[ 95 110]
    [220 260]]
    [[ 95 110]
    [220 260]]

  • @ishansaha6299
    @ishansaha6299 6 ปีที่แล้ว +19

    You python tutorial is best of all waiting for further upload

  • @just_a_living_being
    @just_a_living_being 6 ปีที่แล้ว +13

    from numpy import *
    array1 = zeros((3, 3))
    array2 = zeros((3, 3))
    print('Enter 9 value in first matrix: ')
    for i in range(3):
    for j in range(3):
    array1[i][j] = int(input())
    print('Enter 9 value in second matrix: ')
    for i in range(3):
    for j in range(3):
    array2[i][j] = int(input())
    for i in range(3):
    for j in range(3):
    m = 0
    for t in range(3):
    m = m + array1[i][t] * array2[t][j]
    print(m, end=' ')
    print()

    • @ashwaniyadav3661
      @ashwaniyadav3661 6 ปีที่แล้ว

      its sure work :)

    • @voalcalisticTanmay
      @voalcalisticTanmay 6 ปีที่แล้ว +1

      great!
      can be enhanced more by making it more user friendly and removing ambiguity a bit more.
      Thank you.

    • @0712prasad
      @0712prasad 6 ปีที่แล้ว +1

      what if the matrix is not uniform i.e one is 3*3 and other is 3*4 how to multiply them??

    • @naturearoundme5686
      @naturearoundme5686 6 ปีที่แล้ว

      Iam learning theory from navin sir and code form u great!

    • @vimalraj4846
      @vimalraj4846 5 ปีที่แล้ว

      Can you explain
      m=m+array1[i][t]*array2[t][j]

  • @safwatchoudhury7257
    @safwatchoudhury7257 5 ปีที่แล้ว +7

    works for all kinds of matrix, changing the formation of a and b will work too...
    from numpy import *
    a=array([[2,3],[4,5]])
    b=array([[2,4,3],[8,4,2]])
    c=zeros(len(a)*len(b[0]),int)
    c=c.reshape(len(a),len(b[0]))
    i=0
    k=0
    while i

  • @kirubhaharkannan5461
    @kirubhaharkannan5461 4 ปีที่แล้ว +6

    Matrix Mutiplication , with user inputs :
    from numpy import *
    m1row = int(input("Enter the number of rows of first matrix : "))
    m1column = int(input("Enter the number of columns of first matrix : "))
    m2row = int(input("Enter the number of rows of second matrix : "))
    m2column = int(input("Enter the number of columns of second matrix : "))
    m1 = [[0 for i in range(m1column)] for j in range(m1row)]
    m2 = [[0 for i in range(m2column)] for j in range(m2row)]
    m3 = [[0 for i in range(m2column)] for j in range(m1row)]
    print("Enter the values for First Matrix : ")
    for i in range(m1row):
    for j in range(m1column):
    m1[i][j] = int(input("Enter the value for [" + str(i) + "]" + "[" + str(j) + "] : "))
    print("Enter the values for second Matrix : ")
    for i in range(m2row):
    for j in range(m2column):
    m2[i][j] = int(input("Enter the value for [" + str(i) + "]" + "[" + str(j) + "] : "))
    for i in range(m1row):
    for j in range(m2column):
    res = 0
    for k in range(m2row):
    res += m1[i][k] * m2[k][j]
    m3[i][j] = res
    print("Result matrix value for [" + str(i) + "]" + "[" + str(j) + "] : " + str(m3[i][j]))
    print("Matrix 1 : " + str(m1))
    print("Matrix 2 : " + str(m2))
    print("Matrix resultant : " + str(m3))

  • @reksmeyok1957
    @reksmeyok1957 5 ปีที่แล้ว +19

    the best and enthusiastic video explanation

  • @prasunmondal4572
    @prasunmondal4572 6 ปีที่แล้ว +2

    By taking user input and using inbuilt numpy library:
    import numpy as np
    from numpy import *
    import mathematics as ma
    print(" .........Enter the 1st matrix.........")
    print()
    print("Enter the no of rows: ",end=" ")
    rows1=int(input())
    print("Enter the no of column: ", end=" ")
    columns1=int(input())
    m=[]
    print("Enter all the elements of the matrix following rows to column: ")
    for i in range(rows1*columns1):
    x=float(input())
    m.append(x)
    fmatrix1=np.array(m)
    m1=fmatrix1.reshape(rows1,columns1)
    print()
    print("The 1st Matrix is: ")
    print(m1)
    print()
    print(" .........Enter the 2nd matrix.........")
    print()
    print("Enter the no of rows: ",end=" ")
    rows2=int(input())
    print("Enter the no of column: ", end=" ")
    columns2=int(input())
    n=[]
    print("Enter all the elements of the matrix following rows to column: ")
    for i in range(rows2*columns2):
    y=float(input())
    n.append(y)
    fmatrix2=np.array(n)
    m2=fmatrix2.reshape(rows2,columns2)
    print()
    print("The 2nd Matrix is: ")
    print(m2)
    print()
    print()
    print("The multiplication of two matrices is: ")
    ma1=matrix(m1)
    ma2=matrix(m2)
    ma3=ma1*ma2
    print()
    print(ma3)
    print()
    print(np.dot(ma1,ma2))

  • @mogalheena7875
    @mogalheena7875 4 ปีที่แล้ว +6

    The way u teach is really awesome sir. Thank you sir

  • @ayushmadhu2680
    @ayushmadhu2680 5 ปีที่แล้ว +11

    Sir, I have become a fan of yours.🙌🙌

  • @rosia1948
    @rosia1948 4 ปีที่แล้ว +3

    Thankyou bro... U r the best teacher of coding☺️.... superb explanation 👌👌

  • @thomaslau2362
    @thomaslau2362 4 ปีที่แล้ว +3

    Hi Mr Navin, i got one question and hope that you could address that. For the matrix multiplication what is the scenario that we will actually be using. For statistical calculations?

  • @infoplanet121
    @infoplanet121 6 ปีที่แล้ว +2

    from numpy import *
    m1 = matrix ('1 2 3; 4 5 6 ; 7 8 9 ')
    m2 = matrix ('1 2 3; 4 5 6 ; 7 8 9 ')
    m3 = matrix('0 0 0 ; 0 0 0 ; 0 0 0 ')
    for i in range(3):
    for j in range(3):
    m3[i,j]=0
    for k in range(3):
    m3[i,j] = m3[i,j]+m1[i,k]*m2[k,j]
    print(m3)

  • @swapnilbharude5236
    @swapnilbharude5236 4 ปีที่แล้ว +4

    Hey Navin, I think in the latest update numpy has deprecated i.e. it do not recommend the use of matrix and warns that it would be removed in future

  • @erenxpro099
    @erenxpro099 5 ปีที่แล้ว +5

    Sir m really glad. The way in which you teaches is really very amazing. You put your hard work for making this video, thank you so much for that. ☺️

  • @thenahidul
    @thenahidul 6 ปีที่แล้ว +16

    # Multiplication (R=AxB)
    ===================
    from numpy import *
    A = array([
    [1, 2, 3],
    [4, 5, 6], # 2x3
    ])
    B = array([
    [1, 2, 3],
    [2, 3, 4],
    [4, 5, 6] # 3x3
    ])
    # printing Matrix A
    print("A =", end="")
    for i in range(2): # A row
    for j in range(3): # A column
    print(end="\t")
    print(A[i][j], end="")
    print()
    # printing Matrix B
    print("
    B =", end="")
    for i in range(3): # B row
    for j in range(3): # B column
    print(end="\t")
    print(B[i][j], end="")
    print()
    # creating Matrix R(AxB) blueprint
    R = zeros(6, int).reshape(2, 3) # 2x3(A=row x B=column)
    # AxB operation
    sum = 0
    for i in range(2): # R row
    for j in range(3): # R column
    for k in range(3): # A column
    sum += A[i][k] * B[k][j]
    R[i][j] = sum
    sum = 0
    # printing Matrix R(AxB)
    print("
    R =", end="")
    for i in range(2): # R row
    for j in range(3): # R column
    print(end="\t")
    print(R[i][j], end="")
    print()

    • @prachinainawa3055
      @prachinainawa3055 5 ปีที่แล้ว

      Why don't you print the matrix directly by saying print (R)

  • @faizelahi4147
    @faizelahi4147 6 ปีที่แล้ว +5

    This is one of the best platform on the TH-cam to learn programming
    Thank you telusko learning

  • @pranjalisuryavanshi9698
    @pranjalisuryavanshi9698 3 ปีที่แล้ว +4

    Thank you so much sir !! You teach Python in most easiest & fun way .

  • @golshanswonderland8906
    @golshanswonderland8906 4 ปีที่แล้ว

    Assignment:
    from numpy import*
    arr1= array([[1,2,3],[4,5,6]])
    arr2= array([[7,8],[9,10],[11,12]])
    q= array ([[0,0],
    [0,0]])
    for x in range(2):
    for y in range (2):
    for i in range(3):
    q[x][y]=q[x][y]+ (arr1[x][i]*arr2[i][y])
    print(q)

  • @abhi-ww5ux
    @abhi-ww5ux 10 หลายเดือนก่อน +3

    decent video on python

  • @PB-oc3ph
    @PB-oc3ph 4 ปีที่แล้ว +1

    from numpy import *
    ar = int(input('Enter no. of rows in matrix a:'))
    ac = int(input('Enter no. of columns in matrix a:'))
    br = int(input('Enter no. of rows in matrix b:'))
    bc = int(input('Enter no. of columns in matrix b:'))
    if ac != br:
    print('Multiplication NOT possible')
    else:
    a = zeros((ar, ac), int)
    b = zeros((br, bc), int)
    c = zeros((ar, bc), int)
    for i in range(ar):
    for j in range(ac):
    a[i, j] = int(input('Enter element row wise:'))
    print('matrix A is
    ', a)
    for i in range(br):
    for j in range(bc):
    b[i, j] = int(input('Enter element row wise:'))
    print('matrix B is
    ', b)
    for i in range(ar):
    for j in range(bc):
    x = 0
    for k in range(ac):
    x = a[i, k] * b[k, j] + x
    c[i, j] = x
    print("A*B is
    ", c)

  • @ankursahu4731
    @ankursahu4731 4 ปีที่แล้ว

    Multiplication of two matrix:
    (r1, c1) = shape(m1)
    (r2, c2) = shape(m2)
    arr3 = array([],int)
    x = 0
    for i in range(r1):
    for k in range(c2):
    for j in range(c1):
    x = (arr1[i][j]*arr2[j][k] ) + x
    arr3 = append(arr3,x)
    x=0
    print(arr3)
    m3 = matrix(reshape(arr3,(r1,c2)))
    print(m3)

  • @smitabharadwaj1513
    @smitabharadwaj1513 4 ปีที่แล้ว

    from numpy import *
    tryarray = array([100,26,3,475,5])
    max = tryarray[0]
    currentmax = tryarray[0]
    for x in tryarray:
    print("currentmax", currentmax)
    for j in range(1, len(tryarray)):
    print("value of x", x)
    y = tryarray[j]
    print("value of y", y)
    if(x>y):
    max = x
    print("current value",max)
    else:
    max = y
    print("herevalue",max)
    if(currentmax< max):
    currentmax = max
    print("finalvalue",currentmax)

  • @RonakSantra-v9j
    @RonakSantra-v9j 8 หลายเดือนก่อน

    Respected sir, You are very brilliant. You are covering each and every topics on python. I support you.

  • @partikshagupta9116
    @partikshagupta9116 4 ปีที่แล้ว +1

    "program to multiply 2matrix usin 2d array using for loop"
    from numpy import*
    m1=array([[1,2,3],[4,5,6],[7,8,9]])
    m2=array([[9,8,7],[6,5,4],[3,2,1]])
    m3=[]
    for i in range(0,3):
    m3.append([])
    for j in range(0,3):
    sum=0
    for k in range(0,3):
    sum=sum+(m1[i][k]*m2[k][j])
    m3[i].append(sum)
    print(matrix(m3))

    • @Udayfah
      @Udayfah 4 ปีที่แล้ว

      Could you please explain your code.. I have been trying to understand it but am not getting the for loops

    • @partikshagupta9116
      @partikshagupta9116 4 ปีที่แล้ว

      @@Udayfah First run then debug to understand

    • @akashtalla3136
      @akashtalla3136 4 ปีที่แล้ว +1

      Small Correction to your Code : Range of for loop should not be manually defined, it should take from array rows x columns as below.
      from numpy import *
      M1 = array([[1,3,5],[2,4,6]])
      M2 = array([[2,4],[6,1],[3,5]])
      M3 = []
      print("
      Matrix 1 :
      ", M1, "

      Matrix 2 :
      ", M2)
      if M1.shape[0] == M2.shape[1]:
      for i in range(M1.shape[0]):
      M3.append([])
      for j in range(M2.shape[1]):
      sum = 0
      for k in range(M1.shape[1]):
      sum = sum + (M1[i][k] * M2[k][j])
      M3[i].append(sum)
      print("
      Matrix 1 & Matrix 2 Multiplication using for loop :
      ", matrix(M3))
      Output :
      Matrix 1 :
      [[1 3 5]
      [2 4 6]]
      Matrix 2 :
      [[2 4]
      [6 1]
      [3 5]]
      Matrix 1 & Matrix 2 Multiplication using for loop :
      [[35 32]
      [46 42]]

    • @partikshagupta9116
      @partikshagupta9116 4 ปีที่แล้ว +1

      @@akashtalla3136 thanks for this correction

  • @shivaprasadmallikarjunaiah3751
    @shivaprasadmallikarjunaiah3751 ปีที่แล้ว +1

    You wanted to know did I enjoy this video? ...Absolutely YES from the moment you said "Welcome back Aliens" to "Buh-byeeeee" 😀

  • @onkaryende2334
    @onkaryende2334 4 ปีที่แล้ว +10

    Sir similarly can u pls make a series on c++
    Your teaching ideology is just great and better than other

  • @deeshantgupta3629
    @deeshantgupta3629 3 ปีที่แล้ว +4

    Thank u sir u are doing an amazing job.
    my code to multiply two matrices
    from numpy import *
    b = array([[1, 2, 3], [4, 5, 6]])
    a = array([[4, 5], [6, 2], [3, 9]])
    m = matrix(a)
    n = matrix(b)
    o = m.tolist()
    p = n.tolist()
    d = ''
    for i in range(m.shape[0]):
    for j in range(m.shape[0]):
    v = 0
    for k in range(m.shape[1]):
    v += o[i][k] * p[k][j]
    d += str(v) + ' '
    if i != (n.shape[1] - 1):
    d += '; '
    print(matrix(d))

    • @OliFarhaan
      @OliFarhaan 2 ปีที่แล้ว

      hey buddy, can you explain the if block to me.. I'm not getting it

    • @deeshantgupta3629
      @deeshantgupta3629 2 ปีที่แล้ว

      @@OliFarhaan hmm let me explain it is like, I am concatenating in the string d all the products now to make it matrix I have to add some kind of delimiter i.e. ';' so, normally if we know the rule the size of the matrix will be number of row of first matrix (m)* number of columns of second matrix(n)....... so that's the thing ------> my if block is adding delimiter after getting n number of elements i.e 3 in our case

    • @deeshantgupta3629
      @deeshantgupta3629 2 ปีที่แล้ว

      @VG ARMY hmm let me explain it is like, I am concatenating in the string d all the products now to make it matrix I have to add some kind of delimiter i.e. ';' so, normally if we know the rule the size of the matrix will be number of row of first matrix (m)* number of columns of second matrix(n)....... so that's the thing ------> my if block is adding delimiter after getting n number of elements i.e 3 in our case

  • @rei-rv3py
    @rei-rv3py 4 หลายเดือนก่อน

    from numpy import *
    m = array([
    [1,2],[3,1],[2,3]
    ])
    m1 = array([
    [1,0,2],[2,1,3]
    ])
    result = array([
    [0,0,0],[0,0,0],[0,0,0]
    ])
    for i in range(len(m)):
    for j in range(len(m1[0])):
    for d in range(len(m1)):
    result[i][j] += m[i][d] * m1[d][j]
    print(result)

  • @jitendrachaudhary6271
    @jitendrachaudhary6271 4 ปีที่แล้ว +5

    Thank you sir for this tutorial
    I really like the way you teach

  • @manojhegde9786
    @manojhegde9786 3 ปีที่แล้ว +1

    your lectures are so good , iam enjoying the way you teach python.

  • @mrigayasaini3908
    @mrigayasaini3908 5 ปีที่แล้ว +1

    multiplication of two matrices
    m=matrix('1 2 3;4 5 6;7 8 9')
    m1=matrix('9 8 7;6 5 4;3 2 1')
    m2 =matrix('0 0 0;0 0 0;0 0 0')
    for y in range(0,3):
    for j in range(0,3):
    z=0
    for k in range(0,3):
    z=z+m[y,k]*m1[k,j]
    m2[y,j]=z
    print(m2,int)

    • @sahilsurve5361
      @sahilsurve5361 4 ปีที่แล้ว

      Thanks 😊
      Was looking for it here

  • @rajkumarsubramani8784
    @rajkumarsubramani8784 ปีที่แล้ว +1

    Your videos all are awesome. It will help all people who try to learn python
    Thank you so much sir

    • @easydatascience2508
      @easydatascience2508 ปีที่แล้ว

      Hei , sir, you can see mine too. The channel has both Python Crash course tutorials, and R beginning course tutorials. All the videos have source files downloadable, you can check in the description of the video. Hope they will be useful.

  • @subaananthanam6019
    @subaananthanam6019 3 ปีที่แล้ว +4

    Amazing sir. Could you please explain how to include an unknown variable like x or y in a matrix?

  • @deepakreddyt
    @deepakreddyt 4 ปีที่แล้ว +1

    you are explaining every concept with good examples and ideas
    really thanks a lot.

  • @athirasreekesh4080
    @athirasreekesh4080 4 ปีที่แล้ว

    from numpy import *
    arr1 = array([1,6,3,9])
    b = 0
    for i in range(len(arr1)):
    if arr1[i] >= b:
    b = arr1[i]
    print(b)

  • @mariaxia2687
    @mariaxia2687 4 ปีที่แล้ว

    # multiply 2 matrices using loop
    import numpy as np
    a = np.array([[1, 2, 12], [4, 9, 6]])
    b = np.array([[7, 8], [9, 10], [11, 12]])
    ma, na = a.shape
    mb, nb = b.shape
    c = np.full((ma, nb), 0)
    for i in range(ma):
    for j in range(nb):
    for k in range(na):
    c[i][j] += a[i][k] * b[k][j]
    print(c)

  • @saisankeerthrao7049
    @saisankeerthrao7049 5 ปีที่แล้ว +1

    from numpy import *
    a1 = array([[1,2,3],[4,5,6]])
    a2 = array([[1,2,7],[3,4,8],[5,6,9]])
    if a1.shape[1] == a2.shape[0]:
    r,c = a1.shape
    # c = a2.shape[0] -> Second Matrix Rows
    # r -> First Matrix Rows
    prod = []
    for i in range(0,r):
    row = a1[i]
    pr = []
    for k in range(a2.shape[1]):
    vals = sum([row[j] * a2[j][k] for j in range(c)])
    pr.append(vals)
    prod.append(pr)
    print(prod)
    else:
    print('Multiplication Not possible!!')

  • @b.sasikumar2141
    @b.sasikumar2141 4 ปีที่แล้ว +1

    Ur one the best attribute having person for python sir tq sir..... 🙏🙏🙏

  • @akeebkhan3624
    @akeebkhan3624 4 ปีที่แล้ว

    from numpy import *
    m1 = int(input('enter rows of the metrix '))
    n1= int(input('eter rows of the metrix '))
    A = zeros((m1,n1),int)
    for i in range(m1):
    for j in range(n1):
    x=int(input('enter next element of the metrix'))
    A[i][j]=x
    print(A)
    m2 = int(input('enter rows of the metrix '))
    n2 = int(input('eter rows of the metrix '))
    B = zeros((m2,n2),int)
    for i in range(m2):
    for j in range(n2):
    x=int(input('enter next element of the metrix'))
    B[i][j]=x
    print(B)
    C = zeros((m1,n2),int)
    for i in range(m1):
    for j in range(n2):
    x=0
    for k in range(m2):
    x=x+A[i][k]*B[k][i]
    C[i][j] = x
    print(C)

  • @ramyakrishna3219
    @ramyakrishna3219 5 ปีที่แล้ว

    from numpy import *
    a=ones((3,3),int)
    b=ones((3,3),int)
    result=zeros((3,3),int)
    print(a)
    print(b)
    for i in range(len(a)):
    for j in range(len(b)):
    for k in range(len(b)):
    result[i][j]+=+(a[i][k]*b[k][j])
    for r in result:
    print(r)

  • @freebird682
    @freebird682 4 ปีที่แล้ว

    from numpy import *
    arr1=array([
    [1,2,3],
    [4,5,6]
    ])
    arr2=array([
    [7,8,9],
    [10,11,12]
    ])
    arr3=arr1*arr2
    print(arr3)
    solution for matrix multi[lication

  • @NAVEENKUMARS12
    @NAVEENKUMARS12 3 ปีที่แล้ว

    # Multiplying 2 matrices of any order
    m1 = matrix(input('Type the elements of the first matrix'))
    m2 = matrix(input('Type the elements of the second matrix'))
    c = matrix(array(zeros(m1.shape[0]*m2.shape[1], int).reshape(m1.shape[0],m2.shape[1])))
    if m1.shape[1] != m2.shape[0]:
    print('The matrices cannot be multiplied')
    else:
    print('The matrices can be multiplied')
    for i in range(m1.shape[0]):
    for j in range(m2.shape[1]):
    for k in range(m2.shape[0]):
    c[i,j] += m1[i,k] * m2[k,j]
    for r in c:
    print(r)

  • @sparshagarwal4712
    @sparshagarwal4712 5 ปีที่แล้ว

    from numpy import *
    m1 = array([
    [1,2],
    [3,4]
    ])
    m2 = array([
    [2,1],
    [4,3]
    ])
    m3=array([[0,0],
    [0,0]])
    for i in range(2):
    for j in range(2):
    for k in range(2):
    m3[i,j] = m1[i,k] * m2[k,j] + m3[i,j]
    print(m1)
    print(m2)
    print(m3)

  • @varshithathalavai2477
    @varshithathalavai2477 2 ปีที่แล้ว +1

    Hi sir
    Ur teaching is awesome and I have a question after watching all ur sessions I used to think that I need memorize certain functions what u have thought during the class

  • @brightside1574
    @brightside1574 2 ปีที่แล้ว

    x1 = array(range(0,9)).reshape(3,3)
    print(x1)
    x2 = array(range(1,10)).reshape(3,3)
    print(x2)
    y=x1.dot(x2)
    print(y)

  • @suhailahmed7706
    @suhailahmed7706 3 ปีที่แล้ว

    from numpy import*
    m1=int(input("enter the number of rows of 1 matrix"))
    n1=int(input("enter the number of colmn of 1 matrix"))
    mat1 =zeros((m1,n1),dtype=int)
    u1=len(mat1)
    for i in range(u1):
    for j in range(len(mat1[i])):
    x=int(input("enter the value"))
    mat1[i][j]=x
    print(mat1)
    m2=int(input("enter the number of rows of 2 matrix"))
    n2=int(input("enter the number of colmn of 2 matrix"))
    mat2 =zeros((m2,n2),dtype=int)
    u2=len(mat2)
    for i in range(u2):
    for j in range(len(mat2[i])):
    x=int(input("enter the value"))
    mat2[i][j]=x
    print(mat2)
    new=zeros((m1,n2),dtype=int)
    for i in range(u1):
    for j in range(len(mat2[0])):
    for k in range(u2):
    new[i][j]=new[i][j] + mat1[i][k] * mat2[k][j]
    print("multiplaction of mat1 and mat2 is")
    matr=matrix(new)
    print(type(matr))
    print(matr)

  • @AlladiBalaji-
    @AlladiBalaji- 4 ปีที่แล้ว +1

    What a casual explanation sir

  • @pulastya09
    @pulastya09 3 ปีที่แล้ว

    Q1.Solution :
    # I will just try 2D matrix multiplication
    from numpy import *
    row1=2
    col1=row2=3
    col2=2
    arr1=array([[1,2,4],
    [3,5,6]])
    arr2=array([[0,0],
    [0,2],
    [1,1]])
    # row1,col1=row2,col2 and arr1,arr2 can be arranged a/c to user i/p
    arr1f=arr1.flatten()
    arr2f=arr2.flatten()
    arr3=zeros(4)
    for i1 in range(0,row1):
    for j2 in range(0,col2):
    store=0
    for j1 in range(0, col1):
    store = store + arr1[i1][j1] * arr2[j1][j2]
    arr3[i1*col2+j2]=store
    arr4=arr3.reshape(row1,col2)
    print(arr4)

  • @javedansari3016
    @javedansari3016 4 ปีที่แล้ว

    7:55 I like the way of correction of mistake, in mind something and uttering something

  • @bhavani9873
    @bhavani9873 4 ปีที่แล้ว +1

    You are really a very good teacher , sir 👍👌👌👌👌👌💐

  • @RoronoaZoro-yq1of
    @RoronoaZoro-yq1of 3 ปีที่แล้ว

    from numpy import *
    a = array([[4, 5, 7, 8, 0],
    [1, 2, 3, 4, 5, 6, 10]
    ])
    b = a.flatten()
    print(b)
    o/p:
    [list([4, 5, 7, 8, 0]) list([1, 2, 3, 4, 5, 6, 10])]

  • @hardikjambhule3952
    @hardikjambhule3952 4 ปีที่แล้ว

    from numpy import *
    m1=matrix('1 2 3;4 5 6;7 8 9')
    m2=matrix('4 2 1;7 5 2;6 5 3')
    sum=0
    for i in range(len(m1)):
    for j in range(len(m1)):
    for k in range(len(m1)):
    sum=m1[i,k]*m2[k,j]+sum
    m3[i,j]=sum
    sum=0
    print(m3)

  • @bhojrajrohilla
    @bhojrajrohilla 5 ปีที่แล้ว

    from numpy import *
    arr1=array([[2,4,6],
    [3,6,9],
    [8,12,16]])
    arr2=array([[4,8,12],
    [5,10,15],
    [16,20,24]])
    print("Matrix Multiplication using inbuilt method:",arr1 * arr2)
    print("Matrix Multiplication using for loop")
    for i in range (3):
    ctr=0
    for j in range (3):
    ctr=arr1[i][j]*arr2[i][j]
    print(ctr,end=",")
    print()

  • @FactsDiscoveryyoutube
    @FactsDiscoveryyoutube 5 ปีที่แล้ว +1

    mission completed: final problem of solution
    from numpy import *
    R = int(input("Enter the size of rows:"))
    C =int(input("Enter the size of columns:"))
    m1 = zeros((R,C),int)
    for i in range(R):
    for j in range(C):
    x =int(input("Enter the Element"))
    m1[i][j] =x
    R1 = int(input("Enter the size of rows:"))
    C1 =int(input("Enter the size of columns:"))
    m2 = zeros((R1,C1),int)
    for i in range(R1):
    for j in range(C1):
    x =int(input("Enter the Element"))
    m2[i][j] =x
    print(m1)
    print(m2)
    R2 = int(input("Enter the size of rows:"))
    C2 =int(input("Enter the size of columns:"))
    m3 = zeros((R2,C2),int)
    #itrate through row of m1
    for i in range(len(m1)):
    #itrate through colomns of m2
    for j in range(len(m2[0])):
    #itrate through row of m2
    for k in range(len(m2)):
    m3[i][j]+=m1[i][k]*m2[k][j]

    print(m3)

    output:Enter the size of rows:2
    Enter the size of columns:2
    Enter the Element1
    Enter the Element2
    Enter the Element3
    Enter the Element4
    Enter the size of rows:2
    Enter the size of columns:2
    Enter the Element1
    Enter the Element2
    Enter the Element3
    Enter the Element4
    [[1 2]
    [3 4]]
    [[1 2]
    [3 4]]
    Enter the size of rows:2
    Enter the size of columns:2
    [[ 7 10]
    [15 22]]

    • @vaibhavgupta1708
      @vaibhavgupta1708 5 ปีที่แล้ว

      there is a mistake
      C should be equal to R1 for matrices to be multiplicable

  • @muvvalamounika4300
    @muvvalamounika4300 4 ปีที่แล้ว +10

    Can you help with python interview questions

  • @pritvips
    @pritvips 5 ปีที่แล้ว

    finally got output :)
    from numpy import *
    from array import *
    a1 = array('i',[1,2,3,4])
    print(a1)
    a2 = array('i',[5,6,7,8])
    print(a2)
    a3 = array('i',[])
    m1 = matrix(a1)
    m2 = matrix(a2)
    print(m1)
    print(m2)
    for j in range(1):
    for k in range(2):
    x = (a1[j]*a2[k])+(a1[j+1]*a2[k+2])
    a3.append(x)
    for i in range(2):
    for e in range(1,2,1):
    y = (a1[e+1]*a2[i])+(a1[e+2]*a2[i+2])
    a3.append(y)
    print(a3)
    m3 = matrix(a3)
    print(m3)

  • @prasantaiimk
    @prasantaiimk 4 ปีที่แล้ว +1

    Excellent. Provided explanation is spot on and very clear

  • @JIT100TV
    @JIT100TV 4 ปีที่แล้ว

    The answer of the assignment is:
    import numpy as np
    R = int(input("Enter the number of rows:"))
    C = int(input("Enter the number of columns:"))
    print("Enter {}entries in a single line (separated by space): ".format(R*C))
    #The format() is a method which replaces {} in print function and put the values there.
    # User input of entries in a
    # single line separated by space
    entries = list(map(int, input().split()))
    #The split() method splits a string into a list.You can specify the separator, default separator is any whitespace.
    #string.split(separator, maxsplit)
    if (len(entries))

    • @GowthamChandmanikanta
      @GowthamChandmanikanta ปีที่แล้ว

      copy paste

    • @JIT100TV
      @JIT100TV ปีที่แล้ว

      Ain't No way , You are replying to a 3 year old comment with that bot ass name.
      @@GowthamChandmanikanta

  • @sriramamara5100
    @sriramamara5100 4 ปีที่แล้ว

    your explanation was so good through practically................

  • @T21S154SHARUTHI
    @T21S154SHARUTHI ปีที่แล้ว +1

    easy to understand keep going on ahead

  • @shinylraj4614
    @shinylraj4614 5 ปีที่แล้ว

    #Matrix multiplication 3*2 with 2*3 resulting 3*3
    from numpy import *
    M1=array([
    [7,8],
    [9,10],
    [11,12]
    ])
    M2=array([
    [1,2,3],
    [4,5,6]
    ])
    M_res=array([[0,0,0],[0,0,0],[0,0,0]])
    for i in range(3):
    for j in range(3):
    for k in range(2):
    M_res[i][j]+=M1[i][k]*M2[k][j]
    print(M_res)

  • @IraianReizell
    @IraianReizell 4 ปีที่แล้ว +1

    Thank you always for your tutorial videos! They're very helpful!
    Multiplication Code:
    from numpy import *
    m1 = matrix('4 -3 2; -3 2 9; 9 2 -1')
    m2 = matrix('1 -4 7; 1 1 -1; 10 -8 -2')
    shapem1 = m1.shape
    shapem2 = m2.shape
    if shapem1[1] != shapem2[0]:
    print("Condition for multiplication does not match")
    else:
    m3 = m1 * m2
    print('result with in-built multiplication: ')
    print(m3)
    print()
    resultm = zeros((shapem1[0],shapem2[1]))
    for i in range(shapem1[0]):
    for n in range(shapem2[1]):
    for j in range(shapem1[1]):
    m = j
    resultm[i, n] = resultm[i, n] + m1[i, j] * m2[m, n]
    print('result with self-made multiplication: ')
    print(resultm)
    print('End')

  • @learnwithsachin5169
    @learnwithsachin5169 5 หลายเดือนก่อน

    from numpy import *
    m1 = matrix(' 1 2 3; 4 5 6; 7 8 9')
    m2 = matrix('9 8 7; 6 5 4; 3 2 1')
    print('m1=',m1,'
    ','m2=',m2)
    m3=zeros((m1.shape[0],m2.shape[1]),int) # blank matrix which will be 3*3 (Row of m1 and Col of m2)
    print(m3)
    for i in range(m1.shape[0]): # row in 1st matrix
    for j in range(m2.shape[1]): #col in 2nd matrix
    for k in range(m1.shape[1]): #col in 1st matrix
    m3[i,j]= m3[i,j]+ (m1[i,k]* m2[k,j])
    print((m3))

  • @kunalchatterjee5310
    @kunalchatterjee5310 4 ปีที่แล้ว

    For 3 x 3 matrix (eagerly waiting for reply)
    m1 = np.array([ [1,2,3],[6,4,5],[1,6,7]
    ])
    m2 = np.array([ [1,2,3],[6,8,5],[2,6,7]
    ])
    k = []
    for i in range(len(m1)):
    for j in range(len(m2)):
    x = sum(m1[i]*m2[:,j])
    k.append(x)
    m3 = np.array((k[0:3],k[3:6],k[6:9]))
    print(m3)

  • @luvgupta5500
    @luvgupta5500 4 ปีที่แล้ว

    multiplication code by taking user input
    from numpy import *
    a1=array([ [1,2,3], [4,5,6],[5,6,8],[3,7,1] ])
    r1=int(input("enter no. of rows of mat 1 : "))
    c1= int(input("enter no. of columns of mat 1 : "))
    r2=c1
    c2=int(input("enter no. of columns of mat 2 : "))
    a1=zeros(r1*c1,int).reshape(r1,c1)
    a2=zeros(r2*c2,int).reshape(r2,c2)
    a3=zeros(r1*c2,int).reshape(r1,c2)
    for i in range(r1):
    for j in range(c1):
    a1[i][j]=int(input("enter a1 element : "))
    for i in range(r2):
    for j in range(c2):
    a2[i][j]=int(input("enter a2 element : "))
    m1=matrix(a1);
    print("m1 : ",m1)
    m2=matrix(a2);
    print("m2 : ",m2)
    for i in range(r1):
    for j in range(c2):
    for k in range(r2):
    a3[i][j]=a1[i][k]*a2[k][j] + a3[i][j]
    m3=matrix(a3);
    print("m3 : ",m3)

  • @HarpreetSingh-yw4ln
    @HarpreetSingh-yw4ln 4 ปีที่แล้ว +1

    Hi navin
    Can you please make videos on graphs and implementation using python
    I really like your approach and way of teaching
    please make video on graphs

  • @kittuak7938
    @kittuak7938 2 ปีที่แล้ว +1

    Sir please continue making videos on different types of modules libraries and packages by different types of numerical examples in python

  • @thanishkrishnamurthy1689
    @thanishkrishnamurthy1689 4 ปีที่แล้ว +1

    Hello Sir! i tried an assignment problem myself. Whether i am not sure that code i had done is correct answer for your question or not. plz let me know if it is wrong.
    Que:Write a code to multiply 2 matrices using 2D array and using loop.
    Ans:
    from numpy import *
    arr1 = array ([
    [1,2,3],
    [5,6,8],
    [3,4,6]
    ])
    m1 = matrix(arr1)
    arr2 = array ([
    [4,2,1],
    [8,6,7],
    [3,4,7]
    ])
    m2 = matrix(arr2)
    print(m1)
    print(m2)
    for i in range(1):
    m1 = m1 * m2
    m3 = m1
    print(m3)

  • @varunakavoor
    @varunakavoor 6 ปีที่แล้ว

    from numpy import *
    m1 = [[1,2,3],
    [9,5,6],
    [7,8,10]]
    m2 = [[2,9,6],
    [1,7,2],
    [1,5,9]]
    res =[[0,0,0],
    [0,0,0],
    [0,0,0]]
    for i in range(3):
    for j in range(3):
    for k in range(3):
    res[i][j] += m1[i][k] * m2[k][j]
    for r in res:
    print(r)

  • @shiili7699
    @shiili7699 5 ปีที่แล้ว

    ans:
    import numpy as np
    # input by uesers
    a1 = np.array([[1, 2, 3], [6, 5, 4]])
    a2 = np.array([[6, 5], [9, 5], [6, 2]])
    def matrixMul(arr1, arr2):
    shape1 = np.shape(arr1)
    shape2 = np.shape(arr2)
    if shape1[1] != shape2[0]:
    print("can not be multiplied.")
    else:
    arrMul = np.zeros((shape1[0], shape2[1]))
    for i in range(shape1[0]): # shape1[0] is 2
    for j in range(shape2[1]): # shape2[1] is 2
    for k in range(shape1[1]): # either shape1[1] or shape2[0] is ok
    arrMul[i][j] += arr1[i][k] * arr2[k][j]
    return arrMul

    res = matrixMul(a1, a2)
    print(res)

  • @chessbd
    @chessbd ปีที่แล้ว

    so precious and thanks for your power tutorial......hats off to you and your team!

  • @taruntalwar5422
    @taruntalwar5422 4 ปีที่แล้ว

    Multiplication of Two Matrix by taking Input From User
    from numpy import *
    a1 = int(input("Enter number of rows "))
    b1 = int(input("Enter number of Columns "))
    a2 = int(input("Enter number of rows "))
    b2 = int(input("Enter number of Columns "))
    if b1 == a2:
    c = b1
    ab1 = a1 * b1
    ab2 = a2 * b2
    a1b2 = a1 * b2
    arr1 = (zeros(ab1).reshape(a1, b1))
    arr2 = (zeros(ab2).reshape(a2, b2))
    # print(arr1)
    print("Enter numbers for First Table")
    for i in range(a1):
    for j in range(b1):
    print("Enter the number in Row ", i, " Column ", j, end = " ")
    arr1[i][j]= int(input())
    print("Enter numbers for Second Table")
    for i in range(a2):
    for j in range(b2):
    print("Enter the number in Row ", i, " Column ", j, end = " ")
    arr2[i][j]= int(input())
    print('First Table')
    print(arr1)
    print('Second Table')
    print(arr2)
    arr3 = (zeros(a1b2).reshape(a1, b2))
    for i in range(a1):
    for j in range(b2):
    p = 0
    for k in range(c):
    p = (arr1[i][k] * arr2[k][j]) + p
    arr3[i][j]= p
    print("Multiplication of Both Tables ")
    print(arr3)
    else:
    print("Number of columns of first arr are not equal to number of rows of second array")

  • @k.manideep2543
    @k.manideep2543 5 ปีที่แล้ว +7

    from numpy import *
    arr1 = array([[1,2,3],[4,5,6],[3,4,5]])
    arr2 = array([[1,4,5],[5,4,3],[4,7,8]])
    if(arr1.shape[1] == arr2.shape[0]):
    arr3= []
    for i in range(arr1.shape[0]):
    for j in range(arr2.shape[1]):
    y = 0
    for k in range(arr2.shape[1]):
    x = arr1[i][k]*arr2[k][j];
    y = y+x
    arr3.append(y)
    m = matrix(arr3).reshape(1,3,3)
    print(m)
    else:
    print("Array multiplication is not possible")

    • @manhnguyen-oq4xx
      @manhnguyen-oq4xx 5 ปีที่แล้ว

      could you explain to me:
      shape[1] : mean? how it runs?
      your code is hard to understand, could you explain all to me?

    • @hrithikagarwal6859
      @hrithikagarwal6859 5 ปีที่แล้ว

      How append is working in numpy ?

  • @maheshrdg5764
    @maheshrdg5764 5 ปีที่แล้ว

    from numpy import *
    arr= array([
    [1,2,3],
    [4,5,6],
    [3,3,1]
    ])
    m1= matrix(arr)
    m2=m1
    m3=matrix('0,0,0;0,0,0;0,0,0')
    for k in range(len(m1)):
    for i in range(len(m1)):
    li=[]
    for j in range(len(m2)):
    li.append(m1[k,j]*m2[j,i])
    m3[k,i]=sum(li)
    print(m3)

  • @sumitchowdhury7009
    @sumitchowdhury7009 4 ปีที่แล้ว

    solution:
    from numpy import *
    m1 = matrix('1,2,3;4,5,6')
    m2 = matrix('2,4;5,3;6,7')
    m3 = matrix('0,0;0,0')
    sum = 0
    for i in range(2):
    for j in range(2):
    for k in range(3):
    sum = sum +m1[i,k]*m2[k,j]
    m3[i,j]=sum
    sum = 0
    print(m3)

    • @bhairanganath8249
      @bhairanganath8249 4 ปีที่แล้ว

      It says error shapes (1,2)and (1,2) not aligned :2 (dim 1)! =1 (dim 0)

  • @mubashirabbas5647
    @mubashirabbas5647 4 ปีที่แล้ว +3

    sir please make a video on this assignment multiply of two matrices its so difficult please make a video sir because my concept of matrices is not clear

    • @anuragtiwari9793
      @anuragtiwari9793 4 ปีที่แล้ว

      Class 12th maths first chapter...watch neha mam video, you'll get it

  • @AniketSingh-fu5fg
    @AniketSingh-fu5fg 5 ปีที่แล้ว

    from numpy import *
    arr1=array([])
    arr2=array([])
    n1=int(input('Enter no. of values'))
    for i in range(n1):
    a=int(input('enter a number in array 1: '))
    arr1=append(arr1, a)
    for i in range(n1):
    a = int(input('enter a number in array 2: '))
    arr2=append(arr2, a)
    arr1=arr1.reshape(2,2)
    arr2=arr2.reshape(2,2)
    m1=matrix(arr1)
    m2=matrix(arr2)
    m3=m1*m2
    print(m3)
    arr3=array([])
    for i in range(2):
    for j in range(2):
    b = 0
    for t in range(2):
    a=arr1[i, t]*arr2[t, j]
    b+=a
    arr3=append(arr3, b)
    m3=matrix(arr3)
    m3=m3.reshape(2, 2)
    print(m3)

  • @vakhariyajay2224
    @vakhariyajay2224 2 ปีที่แล้ว +1

    Thank you very much. You are a genius .

  • @joseph481994
    @joseph481994 5 ปีที่แล้ว

    Matrix multiplication:
    from numpy import *
    def mat_mul():
    mat1 = array([
    [1,2,3],
    [4,5,6],
    [7,8,9]
    ])
    mat2 = array([
    [4,5,6],
    [1,2,3],
    [7,8,9]
    ])
    m1,n1 = mat1.shape
    m2,n2 = mat2.shape
    if n1 == m2:
    l1, temp1, temp2 = [], [], []
    for i in range(m1):
    k = 0
    while k

  • @GerardFunClub
    @GerardFunClub ปีที่แล้ว +1

    This is so helpful!!!

  • @manojputhalapattu1469
    @manojputhalapattu1469 5 ปีที่แล้ว

    matrix multiplication
    arr1=[[1,2,3],
    [3,4,5],
    [5,6,1]]
    arr2=[[3,4,5],
    [6,1,2],
    [4,5,6]]
    arr3=[[0,0,0],
    [0,0,0],
    [0,0,0]]
    for b in range(len(arr1)):
    for c in range(len(arr2[0])): #taking coloumn wise values in arr2
    for h in range(len(arr2)):

    arr3[b][c] +=arr1[b][h]*arr2[h][c]
    for j in arr3:
    print(j)
    ##hope this helps

  • @niteshjaiswal2752
    @niteshjaiswal2752 3 ปีที่แล้ว

    from numpy import*
    m = int(input('1st Matrix:- Enter the no. of rows: '))
    n = int(input('1st Matrix:- Enter the no. of columns: '))
    x = matrix([0 for i in range(m*n)])
    for i in range(m*n):
    x[0,i] = int(input("Enter the element for Matrix 1: "))
    r = int(input('2nd Matrix:- Enter the no. of rows: '))
    p = int(input('2nd Matrix:- Enter the no. of columns: '))
    y = matrix([0 for i in range(r*p)])
    for i in range(r*p):
    y[0,i] = int(input("Enter the element for Matrix 2: "))
    m1 = x.reshape(m,n)
    m2 = y.reshape(r,p)
    m3 = m1 * m2
    print("First Matrix is below:-
    ", m1, "
    ", "Second Matrix is below:-
    ", m2, "
    ", "Multiplication of Matrix:-
    ", m3)