Skip to content

Commit 3864c59

Browse files
committed
Added Numpy examples and FAQs section
1 parent 7a8de46 commit 3864c59

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

13-Appendix/01-Programming/02-Python/01-Numpy.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,13 @@ The dot products can be defined for two vectors or matrices in the following way
161161
162162
The value that we obtain for `theta` from the operation above is in radians.
163163

164+
165+
## FAQs
166+
167+
### 1. What is the difference between a List and an NP Array?
168+
There are several differences between an NP Array and a Python List:
169+
170+
1. There is no **append** method on a NP Array while the method works well on Python Lists.
171+
2. Lists can be added with a **+** operator.
172+
3. If `L1 = [1, 2]` and `L2 = [3, 4]`, adding two lists would gives us the concatenation of those lists (`L3 = L1 + L2` would give us the value of `L3` as `[1, 2, 3, 4]`) but adding two Numpy Array would give us the element wise sum for the two Arrays. For example for a Numpy array `A = np.array([1, 2])`, doing `A + A` would give us the value of `A` to be `array([2, 4])`.
173+
4. Numpy lists can be multiplied and added to elements, while the same is not possible with Python Lists. Doing `2 * L1` would repeat all elements in `L1` but doing `2 * A` would multiply each element of the Numpy Array with the constant.

0 commit comments

Comments
 (0)