user42434
0
Q:

create array in python

array = ["1st", "2nd", "3rd"];
#prints: ['1st', '2nd', '3rd']
34
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
19
array = ["1st", "2nd", "3rd"]
#prints: ['1st', '2nd', '3rd']
array.append("4th")
#prints: ['1st', '2nd', '3rd', '4th']
10
#Setting The Array:#

array = [250,630,221] #You can have as many items as you want#

#Printing The Whole Array:#

print(array)
#output = [250, 630, 221,]#

#Printing Individual Items From The Array:#

print(array[0])
#output = 250#

print(array[1])
#output = 630#

print(array[2])
#output = 221#
#array[0] is the 1st array item, array[1] the 2nd, and so on#

#Printing Multiple Items From The Array:#

print(array[2],array[0])
#output = 221#
8
cars = ["Ford", "Volvo", "BMW"] 
2
arr = [1,'string',None,True]
2
int arrayname[arraysize] = {elements,seperated,by,comma}
-1

New to Communities?

Join the community