# Python program to demonstrate
      # the use of index arrays.
      import numpy as np
      
      # Create a sequence of integers from 10 to 1 with a step of -2
      a = np.arrange(10, 1, -2)
      print("\n A sequential array with a negative step: \n",a)
      
      # Indexes are specified inside the np.array method.
      newarr = a[np.array([3, 1, 2 ])]
      print("\n Elements at these indices are:\n",newarr)
      

      Python language logo
      Slicing and advanced indexing

      The output of the above code is:

      A sequential array with a negative step: [-2, 9, 8, 7, 6, 5, 4, 3, 2, 1]

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.