how to use arrays in python code example
Example 1: 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
Example 2: python array
array = ["1st", "2nd", "3rd"];
#prints: ['1st', '2nd', '3rd']
Example 3: array in array python
#You can put multiple arrays in one array
tests = [[1,2,3],["r",22,33]]
#prints: [[1,2,3],['r',22,33]]
Example 4: python create array
variable = []
Example 5: python get array length
# To get the length of a Python array, use 'len()'
a = arr.array(‘d’, [1.1, 2.1, 3.1])
len(a) # Output: 3
Example 6: python print array
#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#