Fall, 2020
Due: Oct 27 by 11:55 pm (London ON time)
Complete the following 5 questions.
Please note that you are not required to complete each question using a single Python command. You may use multiple lines of code. Also please note that there is not one single correct way of completing each question. There are many ways you might code up the solution to each.
Create a 5x5
2D array with \(\pi\) on the border and 0
inside:
3.14159265 3.14159265 3.14159265 3.14159265 3.14159265]
[[3.14159265 0. 0. 0. 3.14159265]
[3.14159265 0. 0. 0. 3.14159265]
[3.14159265 0. 0. 0. 3.14159265]
[3.14159265 3.14159265 3.14159265 3.14159265 3.14159265]] [
Consider the 1x10
1D array Z
:
= np.array([3,1,4,1,5,9,2,6,5,3]) Z
Compute the sum of squared elements of Z
Create a 10x5
2D array containing random integers between 10 and 20, inclusive.
Consider the 1x100
1D array of integers Z
:
= np.random.randint(0,10,100) Z
Print out the unique elements of Z
, sorted in descending order (largest first, smallest last)
Construct a 1x50
array Z
containing the sequence 5,4,3,2,1
repeated 10 times:
5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4
[3 2 1 5 4 3 2 1 5 4 3 2 1]