0% found this document useful (0 votes)
6 views2 pages

NumPy Array Creation Examples

The document contains several code snippets demonstrating the creation of NumPy arrays from lists in Python. It shows how to create one-dimensional and two-dimensional arrays, as well as how to specify data types such as integers and strings. Additionally, it includes an example of creating an array with mixed data types.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

NumPy Array Creation Examples

The document contains several code snippets demonstrating the creation of NumPy arrays from lists in Python. It shows how to create one-dimensional and two-dimensional arrays, as well as how to specify data types such as integers and strings. Additionally, it includes an example of creating an array with mixed data types.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import numpy as np

List1=[10,20,30,40,50]

array1=[Link](List1)

print(array1)

type(array1)

import numpy as np

List1=[[10,20,30],[20,30,40],[50,60,70]]

array1=[Link](List1)

print(array1)

type(array1)

import numpy as np

List1=[10,20.0,30,40,50]

array1=[Link](List1)

print(array1)

type(array1)

import numpy as np

List1=[10, ’Hello’,30,40,50]

array1=[Link](List1)

print(array1)

type(array1)
import numpy as np

List1=[10,20,30,40,50]

array1=[Link](List1, dtype=int)

print(array1)

type(array1)

import numpy as np

List1=[10,20,30,40,50]

array1=[Link](List1, dtype=’U32’)

print(array1)

type(array1)

You might also like