Python NumPy3 Selections Flashcards

1
Q

How do you create a matrix?

A

Create a list of lists, then convert using the numpy array function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you do matrix multiplication?

A

With the dot function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you invert a matrix

A

With the np.linalg.inv function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you compute eigenvalues and eigenvectors?

A

Using the np.linalg.eig method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you select a single value from a NumPy array?

A

Use indexing, for example V[0] or V[5]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you extract a range of values?

A

By slicing, for example, V[2:5] and you can do stuff like this: V[:2] and V[2:]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you set a selection of values in an array equal to a constant?

A

By “broadcasting” for example,
V[4:6] = 33 remember these intervals are half open, like this: [,)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Value assignment propagates

A

Like this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you prevent propagation?

A

By using copy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to select a value from a matrix

A

There are two syntaxes that would work. Both use brackets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to select a submatrix?

A

Do slicing with the colon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Vector operation. How to perform a simple test on every element of an array?

A

Just apply it to the object name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you use that boolean as a selector?

A

Pop it into brackets. Or even do this: V[V>24]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly