1#You can put multiple arrays in one array
2tests = [[1,2,3],["r",22,33]]
3#prints: [[1,2,3],['r',22,33]]
1array = ["1st", "2nd", "3rd"]
2#prints: ['1st', '2nd', '3rd']
3array.append("4th")
4#prints: ['1st', '2nd', '3rd', '4th']
1array = [1,2,3,4,5]
2print(array,array[0],array[1],array[2],array[3],array[4]
3
4#Output#
5#[1,2,3,4,5] 1 2 3 4 5
1#Setting The Array:#
2
3array = [250,630,221] #You can have as many items as you want#
4
5#Printing The Whole Array:#
6
7print(array)
8#output = [250, 630, 221,]#
9
10#Printing Individual Items From The Array:#
11
12print(array[0])
13#output = 250#
14
15print(array[1])
16#output = 630#
17
18print(array[2])
19#output = 221#
20#array[0] is the 1st array item, array[1] the 2nd, and so on#
21
22#Printing Multiple Items From The Array:#
23
24print(array[2],array[0])
25#output = 221#
1import array as arr
2
3numbers_list = [2, 5, 62, 5, 42, 52, 48, 5]
4numbers_array = arr.array('i', numbers_list)
5
6print(numbers_array[2:5]) # 3rd to 5th
7print(numbers_array[:-5]) # beginning to 4th
8print(numbers_array[5:]) # 6th to end
9print(numbers_array[:]) # beginning to end
1# In python, arrays are actually called lists. Same thing tho
2list_or_array = [1.0, 2, '3', True, [1, 2, 3, 4]]
3"""
4So, list can contain floats, integers, strings, booleans, nested lists, and
5practically any other datatype
6"""