Useful NumPy functions you should know! 🎚️
5083 views •
Jan 22, 2026
#python #coding #programming
00:00:00 zeros()
00:01:29 ones()
00:01:52 full()
00:02:16 eye()
00:03:09 empty()
00:03:59 arange()
00:05:16 linspace()
import numpy as np
# Creates an array with zeros
array = np.zeros((2, 3, 10))
print(array)
# Creates an array with ones
array = np.ones((2, 3, 10))
print(array)
# Creates an array with a given value
array = np.full((2, 3), 9)
print(array)
# Creates an array w/o initializing entries
array = np.empty((2, 3))
print(array)
# Creates an identity matrix with 0s and 1s
array = np.eye(5)
print(array)
# Creates an array with evenly spaced values up to a given range
array = np.arange(0, 100, 0.1) # (start, stop, step)
print(array)
# Creates an array with a set number of values that are evenly spaced
array = np.linspace(0, 10, 5) # (start, stop, num)
print(array)
Show more
0 Comments
Sign in to join the conversation.
Sign In