Path: blob/master/3. NumPy exercises.ipynb
107 views

NumPy exercises

Array creation
### Create a numpy array of size 10, filled with zeros.

Create a numpy array with values ranging from 10 to 49

### Create a numpy matrix of 2*2 integers, filled with ones.

Create a numpy matrix of 3*2 float numbers, filled with ones.

Given the X numpy array, create a new numpy array with the same shape and type as X, filled with ones.

Given the X numpy matrix, create a new numpy matrix with the same shape and type as X, filled with zeros.

### Create a numpy matrix of 4*4 integers, filled with fives.

### Given the X numpy matrix, create a new numpy matrix with the same shape and type as X, filled with sevens.

### Create a 3*3 identity numpy matrix with ones on the diagonal and zeros elsewhere.

### Create a numpy array, filled with 3 random integer values between 1 and 10.

Create a 3*3*3 numpy matrix, filled with random float values.

### Given the X python list convert it to an Y numpy array

### Given the X numpy array, make a copy and store it on Y.

Create a numpy array with numbers from 1 to 10

Create a numpy array with the odd numbers between 1 to 10

### Create a numpy array with numbers from 1 to 10, in descending order.

Create a 3*3 numpy matrix, filled with values ranging from 0 to 8

Show the memory size of the given Z numpy matrix

Array indexation
### Given the X numpy array, show it's first element

### Given the X numpy array, show it's last element

### Given the X numpy array, show it's first three elements

### Given the X numpy array, show all middle elements

### Given the X numpy array, show the elements in reverse position

### Given the X numpy array, show the elements in an odd position

Given the X numpy matrix, show the first row elements

Given the X numpy matrix, show the last row elements

Given the X numpy matrix, show the first element on first row

Given the X numpy matrix, show the last element on last row

Given the X numpy matrix, show the middle row elements

Given the X numpy matrix, show the first two elements on the first two rows

Given the X numpy matrix, show the last two elements on the last two rows

Array manipulation
Convert the given integer numpy array to float

Reverse the given numpy array (first element becomes last)

Order (sort) the given numpy array

Given the X numpy array, set the fifth element equal to 1

### Given the X numpy array, change the 50 with a 40

Given the X numpy matrix, change the last row with all 1

Given the X numpy matrix, change the last item on the last row with a 0

Given the X numpy matrix, add 5 to every element

Boolean arrays (also called masks)
Given the X numpy array, make a mask showing negative elements

Given the X numpy array, get the negative elements

Given the X numpy array, get numbers higher than 5

Given the X numpy array, get numbers higher than the elements mean

Given the X numpy array, get numbers equal to 2 or 10

Logic functions
Given the X numpy array, return True if none of its elements is zero

Given the X numpy array, return True if any of its elements is zero

Summary statistics
Given the X numpy array, show the sum of its elements

Given the X numpy array, show the mean value of its elements

Given the X numpy matrix, show the sum of its columns

Given the X numpy matrix, show the mean value of its rows

Given the X numpy array, show the max value of its elements
