Q:

Write a NumPy program to create a random vector of size 10 and sort it

0

Write a NumPy program to create a random vector of size 10 and sort it.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.random.random(10)
print("Original array:")
print(x)
x.sort()
print("Sorted array:")
print(x)

Sample Output:

Original array:                                                        
[ 0.73123073  0.67714015  0.95615347  0.4759837   0.88789818  0.69104042                                                                      
  0.59996415  0.26144489  0.51618644  0.89943882]                      
Sorted array:                                                          
[ 0.26144489  0.4759837   0.51618644  0.59996415  0.67714015  0.69104042                                                                      
  0.73123073  0.88789818  0.89943882  0.95615347]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now