Answers for "numpy array in python"

5

how to import numpy array in python

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

how to make an array python

#arrays and lists are different
#numpy arrays are faster
this_is_a_list = [1, 2, 3]
import numpy #is you do not have it do pip install numpy
this_is_an_array = numpy.array([1, 2, 3])
Posted by: Guest on December-29-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

numpy array [-1]

print(b)
>>array([[ 0,  1,  2,  3],
       [10, 11, 12, 13],
       [20, 21, 22, 23],
       [30, 31, 32, 33],
       [40, 41, 42, 43]])

print(b[-1])       # the last row. Equivalent to b[-1,:]
>>array([40, 41, 42, 43])
Posted by: Guest on April-21-2021
-1

numpy

t = True
f = False
print(type(t)) # Prints "<class 'bool'>"
print(t and f) # Logical AND; prints "False"
print(t or f)  # Logical OR; prints "True"
print(not t)   # Logical NOT; prints "False"
print(t != f)  # Logical XOR; prints "True"
Posted by: Guest on July-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language