This self-assessment is designed to help you review your understanding of the topics covered so far and to allow you to independently evaluate your learning progress. It is structured so that you can identify your strengths and weaknesses and work specifically on areas that still need improvement.
You have two options to test your knowledge. You can use the quiz, which will guide you automatically through the different topics. Alternatively, you will find standard questions below, similar to those used in the script so far.
Please take enough time to work through the questions calmly. Be honest with yourself and try to solve the tasks without any aids in order to get a realistic picture of your current level of knowledge. If you encounter difficulties with a question, it is an indication that you should practice more in that area.
Good luck with the exercises and your continued learning!
Task 1
How is the NumPy package typically imported?
Task 2
Use NumPy to create the following arrays:
Convert the list [1, 2, 3] into a NumPy array
A one-dimensional array containing the numbers from 0 to 9
A two-dimensional array of shape 3×33×3 filled with ones
A one-dimensional array containing numbers from 10 to 50 (inclusive) in steps of 5
Task 3
What is the difference between the functions np.ndim, np.shape, and np.size?
Task 4
What data type does the following array have? Which function can be used to read the data type of an array?
a = np.array([5, 1, 3, 6, 4])b = np.array([6, 5, 2, 6, 9])# 1.result = a + bprint("The sum of both vectors is:", result)# 2.result = a * bprint("The product of both vectors is:", result)# 3.result = a +3print("a plus 3 is:", result)
The sum of both vectors is: [11 6 5 12 13]
The product of both vectors is: [30 5 6 36 36]
a plus 3 is: [8 4 6 9 7]
The appropriate functions are np.loadtxt() and np.savetxt().
Task 10
Image data is typically stored as a 3D matrix, where each color component (usually red, green, and blue) is stored in a separate channel. If the image is stored in a matrix called data, you can isolate a color channel using slicing: data[:, :, 0], where 0, 1, or 2 selects the red, green, or blue channel respectively.