diff --git a/snippets/python/[numpy]/n_dimensional_array.md b/snippets/python/[numpy]/n_dimensional_array.md new file mode 100644 index 00000000..01af50a4 --- /dev/null +++ b/snippets/python/[numpy]/n_dimensional_array.md @@ -0,0 +1,19 @@ +--- +title: N-Dimensional Array Creator +description: Creates an N-dimensional array filled with a single element. +author: Debanjan110d +tags: numpy, arrays, python, n-dimensional +--- + +```py +import numpy as np + +def create_n_dimensional_array(n, fill_value=1): + """Creates an N-dimensional NumPy array filled with a given value.""" + return np.full([1] * n, fill_value) + +# Usage example +if __name__ == '__main__': + array = create_n_dimensional_array(n=3, fill_value=10) + print(array) +``` diff --git a/snippets/python/[numpy}/n_dimensional_array.md b/snippets/python/[numpy}/n_dimensional_array.md new file mode 100644 index 00000000..7e5c1759 --- /dev/null +++ b/snippets/python/[numpy}/n_dimensional_array.md @@ -0,0 +1,18 @@ +--- +title: N-Dimensional Array Creator +description: Creates an N-dimensional array filled with a single element. +author: Debanjan110d +tags: numpy, arrays, python, n-dimensional +--- + +```py +import numpy as np + +def create_n_dimensional_array(n, fill_value=1): + """Creates an N-dimensional NumPy array filled with a given value.""" + return np.full([1] * n, fill_value) + +# Example usage: +# arr = create_n_dimensional_array(3) +# print(arr.ndim) # Output: 3 +``` \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy