python matrix calculation

# A basic code for matrix input from user 
  
R = int(input("Enter the number of rows:")) 
C = int(input("Enter the number of columns:")) 
  
# Initialize matrix 
matrix = [] 
print("Enter the entries rowwise:") 
  
# For user input 
for i in range(R):          # A for loop for row entries 
    a =[] 
    for j in range(C):      # A for loop for column entries 
         a.append(int(input())) 
    matrix.append(a) 
  
# For printing the matrix 
for i in range(R): 
    for j in range(C): 
        print(matrix[i][j], end = " ") 
    print() 

4
9

                                    import numpy
# Two matrices are initialized by value
x = numpy.array([[1, 2], [4, 5]])
y = numpy.array([[7, 8], [9, 10]])
#  add()is used to add matrices
print ("Addition of two matrices: ")
print (numpy.add(x,y))
# subtract()is used to subtract matrices
print ("Subtraction of two matrices : ")
print (numpy.subtract(x,y))
# divide()is used to divide matrices
print ("Matrix Division : ")
print (numpy.divide(x,y))
print ("Multiplication of two matrices: ")
print (numpy.multiply(x,y))
print ("The product of two matrices : ")
print (numpy.dot(x,y))
print ("square root is : ")
print (numpy.sqrt(x))
print ("The summation of elements : ")
print (numpy.sum(y))
print ("The column wise summation  : ")
print (numpy.sum(y,axis=0))
print ("The row wise summation: ")
print (numpy.sum(y,axis=1))
# using "T" to transpose the matrix
print ("Matrix transposition : ")
print (x.T)

4 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
calculate matrix in python python matrix form matrix calculation in python matrix calculation python matrix form python manipulate matrix python how to create a 2x2 matrix in python calculate matrix phyton code to in put matrix of rows and columns matrix in python to find particular number program to input matrix in python of n numbers python matrix calculation Code for taking 4*4 matrix and print first 2 rows and last 2 columns how to read matrix in python input matrix in python numpy how to take matrix as input in numpy python create a 2x2 matrix on input matrix using list in python how to read a matrix in python input matrix in python using numpy scan a matrix in python Fenced Matrix matrix creation in python input 2d array in python matrix function in python how to create matrix with inputpython matrix programs in python how to enter values in matrix from user python create a matrix using list read matrix in python matrix in python input create a matrix of input python how to make matrix in python 2d matric input using comprehension matrix(rows: int, cols: int) in python using function in python number matrix create a matrix in python matrixes problems in python matrix input in python3 python program to read matrix matrix input python input a matrixin python python def examples for a matrix entry of data numpy input matrix understanding matrix problems in python matrix as input in python function to manipulate matrix pythpn how to take input in string and print in 6*6 matrix python how to print matrix of numbers python creating matrix of 5,9 in python python program to print matrix program to print matrix in python matrix questions in python python matric sible input take input matrix in python how to store matrix in python inputting matrix in python representation of n n matrix in python python how to input a matrix printing a matrix in python concept of matrix manipulation using numpy how to input a matrix in python lib for matrix manipulatin python problems on matrices in python matrix input in python read an n by m matrix python print n in pythonp matrix how to get matrix input in python how to take matrix as an input in python input number into matrix python input a 2d matrix in python how to read matrix input in python dynamic matrix in python inputting 2d array in python python square input to matrix character matrix input python matrix with user input numpy how to input n size matrix in python matrices in python how to take matrix as input in python 2d matrix input in python input matrix elements in python how to print matrix with given rows and columns in python 2 d matrix input in one line python matrix problem python function with matrix input python python n*n matrices print matrix elements one by one in python matrix manipulation in python input matrix in python working with matrices in python set function in matrix python how to make matrices in python python represent matrix using list reading a matrix in python matrix in python how to construct matrix in python matrix scanning in python take matrix input in python constructa a matrix in python matrix questions python matrix problems in python python input matrix how to print 1 to 9 3 by 3 maxtrix in python python program to read a matrix take matrix to list in pytho how to print matrix in python numpy matrix operations python matrix operations generate a matrix in python how to take matrix input in python how to take input of matrix row wise in python how to take input of matrix in python get matrix input pygame input of square matrix in python how to create a matrix in python using user input how to make a matrix in python changing summation in cost function to matrix form area of a square using object as arguemnt in cpp check different elements of column matrix in python define different elements of row matrix in python how do you draw a graph from adjacency matrix in javascript how to call matrix in python how to from a matrix in python how to get matrix element in the form of matrix in python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source