Question: In Python 3+, randomly generate a numpy array with 1000 numbers in the shape of (10000,). The numbers should be in the range of 1
In Python 3+, randomly generate a numpy array with 1000 numbers in the shape of (10000,). The numbers should be in the range of 1 and 50 inclusive. Please include screenshots. Then,
- print the first 10 numbers, the last 10 numbers and the variance.
- calculate the difference of every two adjacent numbers in the array. For example, if the original array is [2,4,-1], then the array of difference should be [2, -5] because 4-2=2 and -1-4=-5. You should NOT use a for/while loop.
- calculate the sum of the difference array. Can you get this result without calculation?
- sort the original array.
- print the first 10 numbers, the last 10 numbers and the variance of the sorted array. Is the variance changed?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
