You can use fill method to init the array.

x = np.empty(shape=(800,800))
x.fill(1)
Answer from Wang Hui on Stack Overflow
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ absolute_beginners.html
NumPy: the absolute basics for beginners โ€” NumPy v2.6.dev0 Manual
Using np.newaxis will increase the dimensions of your array by one dimension when used once. This means that a 1D array will become a 2D array, a 2D array will become a 3D array, and so on.
Discussions

How to initialize a two-dimensional array (list of lists, if not using NumPy) in Python? - Stack Overflow
Building a good multidimensional ... using numpy. Nested lists are great for some applications, but aren't usually what someone wanting a 2d array would be best off with. 2010-03-07T17:46:11.297Z+00:00 ... after a few years of occasionally doing serious python apps the quirks ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to generate 2d numpy array? - Stack Overflow
I'm trying to generate a 2d numpy array with the help of generators: More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to create a two-dimensional array using NumPy? - Python - Data Science Dojo Discussions
I have comprehended multiple methods that assist me in defining a one-dimensional array using NumPy. Now, I aspire to master methods that help in developing a two-dimensional array. For this purpose, I have found one method that aids me in defining a 2D array. More on discuss.datasciencedojo.com
๐ŸŒ discuss.datasciencedojo.com
1
0
May 15, 2023
Initializing 1-D and 2-D arrays ___ Is there a shorter or standard way to write this ?

res = [0] * 100

More on reddit.com
๐ŸŒ r/Python
15
8
June 27, 2019
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ basics.creation.html
Array creation โ€” NumPy v2.5 Manual
NumPy arrays can be defined using Python sequences such as lists and tuples. Lists and tuples are defined using [...] and (...), respectively. Lists and tuples can define ndarray creation: a list of numbers will create a 1D array, a list of lists will create a 2D array, further nested lists will create higher-dimensional arrays.
๐ŸŒ
Python Guides
pythonguides.com โ€บ python-numpy-2d-array
Create A 2D NumPy Array In Python (5 Simple Methods)
May 9, 2025 - Python has no built-in 2D array type, so you use either a nested list (a list of rows, like [[1, 2], [3, 4]]) or a NumPy 2D array created with np.array(), np.zeros() and similar functions.
๐ŸŒ
OpenGenus
iq.opengenus.org โ€บ 2d-array-in-numpy
2D Arrays in NumPy (Python)
October 28, 2022 - ... To get a specific element from an array use arr[r,c] here r specifies row number and c column number. ... To get all elements of Row or Column : is used to specify that we need to fetch every element. arr[1,:] #This will return all elements of 1st row in the form of array ...
๐ŸŒ
Replit
replit.com โ€บ home โ€บ discover โ€บ how to initialize a 2d array in python
How to initialize a 2D array in Python | Replit
Understanding proper techniques for copying lists in Python is essential for avoiding these shallow copy issues. ... For numerical computing, the NumPy library is the standard. You can create a 2D array by passing a list of lists to the np.array() ...
๐ŸŒ
W3docs
w3docs.com โ€บ home โ€บ code snippets โ€บ python โ€บ how to initialize a two-dimensional array in python?
How to initialize a two-dimensional array in Python? | W3docs
You can use the built-in list function to create a 2D array (also known as a list of lists) in Python. Here is an example of how to create a 2D array with 3 rows and 4 columns, filled with zeroes: ... Alternatively, you can use numpy library, ...
Find elsewhere
๐ŸŒ
Python Guides
pythonguides.com โ€บ initialize-a-2d-array-in-python
How to Initialize a 2D Array in Python?
July 22, 2026 - NumPy is a third-party library for numeric computing in Python. It is not part of the standard library, so you need to install it first with pip install numpy. If it is already on your machine, these functions build 2D arrays fast, and they avoid the shared-reference trap entirely.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-using-2d-arrays-lists-the-right-way
Python | Using 2D arrays/lists the right way - GeeksforGeeks
When working with structured data or grids, 2D arrays or lists can be useful. A 2D array is essentially a list of lists, which represents a table-like structure with rows and columns. In Python, Initializing a collection of elements in a linear sequence requires creating a 1D array, which is a fundamental process.
Published: June 20, 2024
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to create a two dimensional array in python?
How To Create a Two Dimensional Array in Python? - Be on the Right Side of Change
June 11, 2022 - Once installed, you can import the Numpy module and use its functions and modules to work with multidimensional arrays. To create a 2D array loaded with zeros, you can simply use the numpy.zeros() method.
๐ŸŒ
DataCamp
campus.datacamp.com โ€บ courses โ€บ intro-to-python-for-data-science โ€บ chapter-4-numpy
2D NumPy Arrays | Python
If you ask for the type of these arrays, Python tells you that they are numpy.ndarray. numpy dot tells you it's a type that was defined in the numpy package. ndarray stands for n-dimensional array. The arrays np_height and np_weight are one-dimensional arrays, but it's perfectly possible to create 2 dimensional, three dimensional, heck even seven dimensional arrays! Let's stick to 2 in this video though. You can create a 2D numpy array from a regular Python list of lists.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-initialize-numpy-array-of-list-objects-a-comprehensive-guide
How to Initialize Numpy Array of List Objects: A Guide | Saturn Cloud Blog
May 1, 2026 - This will achieve the same result as using `np.array()``. ... import numpy as np # Step 2: Create a List list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8] # Step 3: Convert List to Numpy Array using np.array() array_nparray = np.array([list1, list2]) ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-using-2d-arrays-lists-the-right-way
Using 2D arrays/lists in Python - GeeksforGeeks
Python creates only one inner list and one 0 object, not separate copies. This shared reference behavior is known as shallow copying (aliasing). If we assign the 0th index to another integer say 1, then a new integer object is created with the value of 1 and then the 0th index now points to this new int object as shown below ยท Similarly, when we create a 2d array as "arr = [[0]*cols]*rows" we are essentially extending the above analogy.
Published: December 20, 2025
๐ŸŒ
MLJAR
mljar.com โ€บ answers โ€บ define-two-dimensional-array-python
Define two-dimensional array in Python
array[2][2] = 5 # valid array[7][2] = 3 # error ยท This way is much easier. You can use zeros function from numpy to create 2D array with all values set to zero: import numpy array = numpy.zeros((4,4)) REMEMBER Even though the second version is easier, the first one is better for this operation unless we need any matrix operations.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ ndarray-creation
NumPy N-D Array Creation (With Examples)
import numpy as np # Create a 2-D array with elements initialized to 5 numpy_array = np.full((2, 2), 5) print("Array:", numpy_array) ... Here, we have used the np.full() function to create a 2-D array where all elements are initialized to 5. The np.random.rand() function is used to create an ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_creating_arrays.asp
NumPy Creating Arrays
To create an ndarray, we can pass a list, tuple or any array-like object into the array() method, and it will be converted into an ndarray: ... A dimension in arrays is one level of array depth (nested arrays). nested array: are arrays that ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ multi-dimensional-arrays-in-python
Multi-Dimensional Arrays in Python โ€“ Matrices Explained with Examples
December 11, 2025 - In Python, you can create multi-dimensional arrays using various libraries, such as NumPy, Pandas, and TensorFlow.
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ python
How to create a two-dimensional array using NumPy? - Python - Data Science Dojo Discussions
May 15, 2023 - I have comprehended multiple methods that assist me in defining a one-dimensional array using NumPy. Now, I aspire to master methods that help in developing a two-dimensional array. For this purpose, I have found one metโ€ฆ