Answers for "how to make an array in python"

10

how to make a numpy array

>>> x = np.array([2,3,1,0])
>>> x = np.array([2, 3, 1, 0])
>>> x = np.array([[1,2.0],[0,0],(1+1j,3.)]) # note mix of tuple and lists,
    and types
>>> x = np.array([[ 1.+0.j, 2.+0.j], [ 0.+0.j, 0.+0.j], [ 1.+1.j, 3.+0.j]])
Posted by: Guest on August-08-2020
6

for element in array python

itemlist = []
for j in range(len(myarray)):
    item = myarray[j]
    itemlist.append(item)
Posted by: Guest on May-14-2020
20

how to create an array in python

array = ["1st", "2nd", "3rd"]
#prints: ['1st', '2nd', '3rd']
array.append("4th")
#prints: ['1st', '2nd', '3rd', '4th']
Posted by: Guest on November-28-2019
54

python array

array = ["1st", "2nd", "3rd"];
#prints: ['1st', '2nd', '3rd']
Posted by: Guest on December-19-2019
21

python arrays

array = [1,2,3,4,5]
print(array,array[0],array[1],array[2],array[3],array[4]

#Output#
#[1,2,3,4,5] 1 2 3 4 5
Posted by: Guest on March-07-2020
3

how to make an array in python

#use numpy
import numpy #if you don't have it do pip install numpy
array = numpy.array(["Ford", "Volvo", "BMW"] )
Posted by: Guest on December-29-2020

Code answers related to "how to make an array in python"

Python Answers by Framework

Browse Popular Code Answers by Language