Python Programming: Lesson 64 - More Techniques for Matrices and the eval Function

Опубликовано: 09 Ноябрь 2021
на канале: youmils03
37
0

PLEASE SUBSCRIBE!!!

In the previous lesson (   • Python Programming: Lesson 63 - Techn...  ), we took a look at matrices, which are lists or tuples of lists or tuples containing ints or floats. There are some numeric operations that we're familiar with from linear algebra, which can be implemented via static and class methods in an Arrays class.

To add two matrices together, add their corresponding entries
To subtract two matrices, subtract their corresponding entries
To find the minimum or maximum element in a matrix, make sure that you have a _lt_ magic method in your class. Then, find the minimum in each list or tuple within the matrix, collect it into a list of minimum elements, and then find the minimum within that. Maximum is similar.
The number of entries in a matrix is given by the number of rows times the number of columns.
The transpose of a matrix swaps the rows and columns.

In this video, we also consider eval(x). The eval function accepts a string and returns the value of the expression wrapped inside of the string. So, 5 + eval("2") = 7, and eval("le" + "n([5])") = 1

0:35 Review of exec(x) and Iterators
3:20 Review of Adding, Subtracting, and Maximum/Minimum Element of Matrices
7:43 NEW: Corner Elements, Number of Elements, and Transpose of a Matrix
15:59 NEW: eval(x) accepts a string x and returns the literal value within the string

In the next video, we will talk more about the exec function, iterators, the eval function, and matrices. Lots to review! AND, we get a new topic. What a cool 20 minutes, on top of the cool 20 minutes in this video:    • Python Programming: Lesson 65 - JSON ...  

Thanks for watching, and PLEASE SUBSCRIBE!!!