## Numpy and Loops in Python

This introductory homework assignment solution covers Numpy and loops (for and while) in Python. The example problems use simple vectors and matrices, reshaping, index referencing, initialization, dot product, cross product, matrix inverse, size, and range.

Source

### Comment List

• APMonitor.com
November 28, 2020

Thank you!

• APMonitor.com
November 28, 2020

I'm using your lessons to familiarize myself with python and then teach myself CFD. You are the man

• APMonitor.com
November 28, 2020

Hi!
I didn't understand how did Pyhton compute the inverse of matrix A since its determinant is zero (thus it has no inverse).
I tried to calculate the determinant and it gave me something like -9.51619735393e-16 so maybe this is a question of precision?
Thanks!

• APMonitor.com
November 28, 2020

I very much appreciate the time you spend to help others. It is a huge benefit to us seeking knowledge. Thank you. Something to consider is re-watching your videos and trying to place yourself in the mind of your intended audience and think about any questions that might come to mind and then re-do or add these clarifications. For example, you create a for loop for the number of rows (for i in np.size…) and columns (for j in …), but don't explain why or what the iteration is doing. It seems to just be getting the correct number of iterations, but I'm not sure. And you don't explain i and j. Are these special variables somehow? How are they used. And what does i iteration and j iteration do — like really?