Important Notice:

Course Content
NumPy Basic in Python (Chapter-13) M3-R5
About Lesson

Create 2 Dimensional Array Using User Input:-

 

#creating 2D array

import numpy as np

matrix=[]

row=int(input(“Enter number of row”))

col=int(input(“Enter number of column “))

for i in range(row):

    a=[]

    for j in range(col):

        val=int(input(“enter value “))

        a.append(val)

    matrix.append(a)

arr=np.array(matrix)

for i in range(row):

    for j in range(col):

        print(arr[i][j],end=” “)

    print()

print(type(arr))

 

#creating 2D array using user input

import numpy as np

matrix=[]

row=int(input(“Enter number of row”))

col=int(input(“Enter number of column “))

for i in range(row):

    a=[]

    for j in range(col):

        val=int(input(“enter value “))

        a.append(val)

    matrix.append(a)

for i in range(row):

    for j in range(col):

        print(matrix[i][j],end=” “)

    print()

 

error: Content is protected !!