import numpy as np
a = np.arange(72)
a = np.reshape(a, (4,3,2,3))
or:
a = np.array([[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]]])
or:
a = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]])
a = np.expand_dims(a, axis=0)
a = np.repeat(a, 4, axis=0)
Answer from Sơn Ninh on Stack OverflowPython
docs.python.org › 3 › library › array.html
array — Efficient arrays of numeric values — Python 3.15.2 documentation
1 month ago - This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers, complex numbers. Arrays are mutable sequence types and behave very much like lists, except that the type ...
Can I create an array where each field has 4 values?
Use a list of named tuples. https://docs.python.org/3/tutorial/datastructures.html https://docs.python.org/3/library/collections.html Actually, you can use a regular tuple, but accessing the data by name is pretty convenient. More on reddit.com
python - How do I create a custom 4x4 array using NumPy? - Stack Overflow
I am new to Python and I am having a bit of trouble with the array functions. I want to make a 4 by 4 array which contains the numbers from 1 to 16. I know that using np.zeros((4,4)) outputs a 4x4 More on stackoverflow.com
arrays - What does {:4} mean in this matrix printing solution in python? - Stack Overflow
In the solution to the question proposed here printing a two dimensional array in python I'm not able to figure out what the {:4} part of the solution means exactly. I've tried this print statement... More on stackoverflow.com
Making a 4x4 array in python - Stack Overflow
I am trying to create a 4x4 array looking something like this:This is a javascript code that I'm trying to create into python More on stackoverflow.com
07:43
NumPy multidimensional arrays are easy! 🧊 - YouTube
Creating 1 2 3 4 Dimensional Array Using Numpy
05:25
ARRAYS in Python - Start Here! - YouTube
12:23
Intro to Python Part I: Creating and Initializing Arrays - YouTube
09:10
How to build an array in Python - YouTube
GeeksforGeeks
geeksforgeeks.org › python › python-arrays
Python Arrays - GeeksforGeeks
1 array('i', [1, 2, 3, 5]) Explanation: parameter 'i' is the typecode, it tells Python to treat the elements as signed integers ([1, 2, 3]) of a specific byte size (usually 2 or 4 bytes). The following table outlines standard typecodes, their mapped C types and minimum memory requirements: Array can be created by importing an array module.
Published: September 19, 2026
Reddit
reddit.com › r/learnpython › can i create an array where each field has 4 values?
r/learnpython on Reddit: Can I create an array where each field has 4 values?
August 3, 2021 -
Basically, I need to create an array where each field has 4 values: an address, name, number and age. I am kinda new to programming and am unsure how to do this. Is there a built in function in python, or is there a library I can use that will enable this?
Top answer 1 of 6
9
You could use a multi-dimensional array Or a dictionary Or an array of dictionary objects Or you could store everything in a JSON object and use the native JSON Library in python to parse and access the fields
2 of 6
8
Use a list of named tuples. https://docs.python.org/3/tutorial/datastructures.html https://docs.python.org/3/library/collections.html Actually, you can use a regular tuple, but accessing the data by name is pretty convenient.
Programiz
programiz.com › python-programming › array
Python Array of Numeric Values
March 26, 2024 - Note: When people say arrays in Python, more often than not, they are talking about Python lists. If that's the case, visit the Python list tutorial. To create an array of numeric values, we need to import the array module. For example: import array as arr a = arr.array('d', [1.1, 3.5, 4.5]) print(a)
New York University
physics.nyu.edu › pine › pymanual › html › chap3 › chap3_arrays.html
3. Strings, Lists, Arrays, and Dictionaries — PyMan 0.9.31 documentation
The NumPy library has a large set of routines for creating, manipulating, and transforming NumPy arrays. NumPy functions, like sqrt and sin, are designed specifically to work with NumPy arrays. Core Python has an array data structure, but it’s not nearly as versatile, efficient, or useful as the NumPy array.
Real Python
realpython.com › python-array
Python's Array: Working With Numeric Data Efficiently – Real Python
May 13, 2026 - >>> fibonacci_numbers[2:9:3] = array("I", [3, 13, 55, 233]) Traceback (most recent call last): ... ValueError: attempt to assign array of size 4 to extended slice of size 3 · As with any sequence, you must ensure that the replacement slice has the same length as the one that you’re replacing when you use the extended syntax. That’s because the extra elements would produce gaps in your sequence, which must remain contiguous. On the other hand, regular slices with a step equal to one don’t have such a limitation. Note: Check out Python’s Mutable vs Immutable Types to learn more about the differences between both kinds of data types.
Stack Overflow
stackoverflow.com › questions › 68716275 › making-a-4x4-array-in-python
Making a 4x4 array in python - Stack Overflow
import numpy as np height, width = 4, 4 num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] array = np.array(num).reshape((height, width)) print(array)
Princeton University
introcs.cs.princeton.edu › python › 14array
Arrays in Python
In its most basic form, an array supports four core operations: creation, indexed access, indexed assignment, and iteration. In this booksite, we use Python's built-in list data type for arrays because it supports these basic operations. We consider more elaborate operations supported by Python's ...
Nanyang Technological University
libguides.ntu.edu.sg › python › arrayslicing
NP.4 Array Slicing - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
August 26, 2026 - Learn practical Python programming skills for basic data manipulation and analysis. ... Array slicing is similar to list slicing in Python. Array indexing also begins from 0. However, since arrays can be multidimensional, we have to specify the slice for each dimension.