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,

  1. print the first 10 numbers, the last 10 numbers and the variance.
  2. 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.
  3. calculate the sum of the difference array. Can you get this result without calculation?
  4. sort the original array.
  5. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!