numpy example
>>> import numpy as np
>>> a = np.array([0, 1, 2, 3])
>>> a
array([0, 1, 2, 3])
numpy example
>>> import numpy as np
>>> a = np.array([0, 1, 2, 3])
>>> a
array([0, 1, 2, 3])
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]])
python numpy array
import numpy as np
ary=np.array([1, 2, 3, 4])
print(ary[0]) # 1
print(ary[2]) # 3
print(ary[::2]) # array([1, 3])
np.array
x = np.array([ [67, 63, 87],
[77, 69, 59],
[85, 87, 99], # Creates an array, with arrays
[79, 72, 71],
[63, 89, 93],
[68, 92, 78]])
# its shape is [6,3] | 6 beeing its "height" and 3 its "width"
# if you want to to get this inffo about this array you can search for it
#just like you were searching for itens in an array, like:
fatness_of_the_array-x = x.shape[1] # 1 is refering to the width commented earlier
numpy
x = 3
print(type(x)) # Prints "<class 'int'>"
print(x) # Prints "3"
print(x + 1) # Addition; prints "4"
print(x - 1) # Subtraction; prints "2"
print(x * 2) # Multiplication; prints "6"
print(x ** 2) # Exponentiation; prints "9"
x += 1
print(x) # Prints "4"
x *= 2
print(x) # Prints "8"
y = 2.5
print(type(y)) # Prints "<class 'float'>"
print(y, y + 1, y * 2, y ** 2) # Prints "2.5 3.5 5.0 6.25"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us