1>>> import numpy as np
2>>> a = np.array([0, 1, 2, 3])
3>>> a
4array([0, 1, 2, 3])
5
1import numpy as np
2
3ary=np.array([1, 2, 3, 4])
4
5print(ary[0]) # 1
6print(ary[2]) # 3
7print(ary[::2]) # array([1, 3])
1x = np.array([ [67, 63, 87],
2 [77, 69, 59],
3 [85, 87, 99], # Creates an array, with arrays
4 [79, 72, 71],
5 [63, 89, 93],
6 [68, 92, 78]])
7
8# its shape is [6,3] | 6 beeing its "height" and 3 its "width"
9
10# if you want to to get this inffo about this array you can search for it
11#just like you were searching for itens in an array, like:
12
13fatness_of_the_array-x = x.shape[1] # 1 is refering to the width commented earlier
14
15
16
1x = 3
2print(type(x)) # Prints "<class 'int'>"
3print(x) # Prints "3"
4print(x + 1) # Addition; prints "4"
5print(x - 1) # Subtraction; prints "2"
6print(x * 2) # Multiplication; prints "6"
7print(x ** 2) # Exponentiation; prints "9"
8x += 1
9print(x) # Prints "4"
10x *= 2
11print(x) # Prints "8"
12y = 2.5
13print(type(y)) # Prints "<class 'float'>"
14print(y, y + 1, y * 2, y ** 2) # Prints "2.5 3.5 5.0 6.25"
15