Create a vector with values ranging from 1 to 20 using NumPy.

In this python numpy program, we will create a vector with values ranging from 1 to 20 using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create a vector with values ranging from 1 to 20 using np.arange().
  3. Print the output.
				
					import numpy as np
x = np.arange(1,21)

print("Array: ",x)
				
			

Output :

				
					Array:  [ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20]
				
			

generate an array of 5 random numbers from a standard normal distribution.

print all the values from the array except 20 using NumPy.

Leave a Comment