Answers for "square of matrix in python"

1

create square matrix python

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()
Posted by: Guest on June-11-2020
-1

square python np

import numpy as np

# ints
array_2d = np.array([[1, 2, 3], [4, 5, 6]])

print(f'Source Array:n{array_2d}')

array_2d_square = np.square(array_2d)

print(f'Squared Array:n{array_2d_square}')
Posted by: Guest on November-12-2020

Code answers related to "square of matrix in python"

Python Answers by Framework

Browse Popular Code Answers by Language