Python NumPy program to print all the values from the array.

In this python numpy program, we will print all the values from the array except 20 using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array of 1-20 numbers using np.range().
  3. Use for loop to iterate over the numbers in the array.
  4. If the number is not equal to 20 then print that number.
				
					import numpy as np
x = np.arange(1,20)

for val in x:
    if val != 20:
        print(val,end=" ")
				
			

Output :

				
					1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 
				
			

create a vector with values ranging from 1 to 20.

print all the values from the above array except 1 using NumPy.

Leave a Comment