Replace all odd numbers in the given array with -1
Start with:
exercise_1 = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Desired output:
[ 0, -1, 2, -1, 4, -1, 6, -1, 8, -1]
Convert a 1-D array into a 2-D array with 3 rows
Start with:
exercise_2 = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8])
Desired output:
[[ 0, 1, 2] [3, 4, 5] [6, 7, 8]]
Add 202 to all the values in given array
Start with:
exercise_3 = np.arange(4).reshape(2,-1)
Desired output:
[[202, 203] [204, 205]]
Generate a 1-D array of 10 random integers. Each integer should be a number between 30 and 40 (inclusive)
Sample of desired output:
[36, 30, 36, 38, 31, 35, 36, 30, 32, 34]
Your answer may contain different values but should fulfill the question requirements.
Find the positions of:
Start with these:
x = np.array([21, 64, 86, 22, 74, 55, 81, 79, 90, 89]) y = np.array([21, 7, 3, 45, 10, 29, 55, 4, 37, 18])
Desired output:
(array([1, 2, 4, 5, 6, 7, 8, 9]),) and (array([0]),)
Extract the first four columns of this 2-D array
Start with this:
exercise_6 = np.arange(100).reshape(5,-1)
Desired output:
[[ 0 1 2 3] [20 21 22 23] [40 41 42 43] [60 61 62 63] [80 81 82 83]]