asked 188k views
2 votes
Write a program named double_trouble.py that contains a 2-D array containing two arrays with the values 1,2,3 and 4,5,6. Check and report on the array's dimensions.

1 Answer

1 vote

Answer:

import numpy as np

list1 = [1,2,3]

list2 = [4,5,6]

my_array = np.array([list1, list2])

print( my_array )

print( my_array.shape)

Step-by-step explanation:

To create a 2- dimensional array from two list or arrays, import the numpy package and call the numpy array method with the two arrays as the argument. Print the resultant array and the dimension with the numpy shape attribute.

answered
User Jessehz
by
7.9k points