Answers for "np.array"

5

numpy example

>>> import numpy as np
>>> a = np.array([0, 1, 2, 3])
>>> a
array([0, 1, 2, 3])
Posted by: Guest on April-21-2020
10

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]])
Posted by: Guest on August-08-2020
0

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])
Posted by: Guest on October-08-2021
0

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
Posted by: Guest on September-09-2021
0

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"
Posted by: Guest on July-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language