Перейти к содержимому

NumPy Practice | Level 2: Indexing & Slicing (Q6–Q10) | Raw Problem Solving

A.Kr.M.

0:00 / 0:00

NumPy Practice | Level 2: Indexing & Slicing (Q6–Q10) | Raw Problem Solving

1 просмотр · 12 дней назад
A.Kr.M.
1 просмотр · 12 дней назад
Continuing my NumPy learning and practice journey 🐍 In this raw problem-solving recording, I worked through **Level 2: Indexing & Slicing (Q6–Q10)**. Topics covered: Basic 1-D array indexing Positive and negative indexing Array slicing with `start:stop:step` Reversing an array using slicing 2-D array indexing Selecting rows and columns 2-D array slicing Using `np.where()` to find the position of a value Mistakes / corrections from this practice: 🔹 *Q7: Last 3 elements* I initially used: `arr[-1:2:-1]` This gives the last 3 elements in reverse order: `[60, 50, 40]`. For the requested last 3 elements in normal order, the correct and simpler approach is: `arr[-3:]` 🔹 *Q9: Finding values in a 2-D array* For values such as `50`, `90`, and `20`, I initially used `np.where()` because I interpreted the question as finding the position of a value when its location is unknown. `np.where()` is useful for exactly that situation. However, when the row and column position is already known, direct indexing is simpler: `arr2[1, 1]` → `50` `arr2[2, 2]` → `90` `arr2[0, 1]` → `20` 🔹 *Q9: Selecting the third column* I initially tried a more complicated indexing approach. During review, I learned the much cleaner syntax: `arr2[:, 2]` Here `:` means all rows, while `2` refers to column index 2. 🔹 *Q10: 2-D slicing* My original indexing produced the correct output, but I learned that basic 2-D slicing can be expressed more clearly as: `arr2[0:2, 0:2]` and `arr2[1:3, 1:3]` The general pattern is: `array[row_slice, column_slice]` This was a useful practice session because some of the mistakes were not syntax errors, but simply patterns I had not encountered yet. This channel is my personal record of learning, practicing, recording, and uploading my progress. I am keeping these recordings raw so I can look back at how my problem-solving develops over time. #Python #NumPy #PythonPractice #NumPyPractice #CodingJourney #LearnPython #Programming #DataScience #PythonLearning