How can we handle matrices and vector operations in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can we handle matrices and vector operations in python?

Information required on how to define matrix and perform opertions in python

10th Sep 2017, 3:07 AM
Ahmed Siddique
Ahmed Siddique - avatar
6 Answers
+ 1
Thanks for your help
10th Sep 2017, 3:43 AM
Ahmed Siddique
Ahmed Siddique - avatar
0
a=[[1,2,3],[4,5,6],[7,8,9]] this is a 3×3 matrix
10th Sep 2017, 3:23 AM
sayan chandra
sayan chandra - avatar
0
okk. can you tell me how to perform operations like addition, multiplications & inverse. I have tried a*b for two matrices but that did not work
10th Sep 2017, 3:35 AM
Ahmed Siddique
Ahmed Siddique - avatar
0
I type this but I get an IndentationError why??
6th Oct 2017, 3:08 AM
Nathalia Alvarez
Nathalia Alvarez - avatar
- 1
a is a matrix... b is a matrix... so u do.... first declare a c matrix loaded with 0 like c=[[0]*n for i in range(n)] c is a n×n matrix...all 0 elements now .. for i in range(n) : for j in range(n) : c[i][j]=a[i][j]+b[i][j] now your task is to implement the multiplication..... u know the mathematics just convert it to code
10th Sep 2017, 3:39 AM
sayan chandra
sayan chandra - avatar
- 1
typed what Nathalia@ ??
6th Oct 2017, 3:09 AM
sayan chandra
sayan chandra - avatar