w8 Flashcards

(27 cards)

1
Q

whats numpy

A

fundamental package for scientific computing with python

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

Difference between arrays and lists

A
  • All the elements in them are of the same type i.e all strings, all ints
  • Arrays are multidimensional
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Advantages of arrays

A
  • Calculations using arrays are much faster than lists
  • Very fast libraries for manipulating arrays
  • Python provides convenient features for performing numerical calcs with arrays
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why calcs using arrays much faster than lists

A

Because data in an array is sequential in memory (in a block) - making it easy to access
This is contrasted to lists and tuples who have data located fragmentally and at various points in the computer library

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

what are one-dimensional arrays referred to as

A

vectors

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

what are two-dimensional arrays referred to as

A

matrices

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

when [:] is sliced, what does it actually slice

A

the whole thing

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

whats the general formula for 2-dimensional slicing

A

sliced_matrix = matrix[row_start:row_end, column_start:column_end]

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

Contiguous vs Non-contiguous set of data

A

contiguous data is where python gives us a view when sliced and any changes to the view will affect the original

non-contiguous data is where python just gives us a copy of the data

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

How are arrays added and subtracted

A

perfumed “element-wise”: elements of each array are matched up into their corresponding pairs and operation is performed on the pair

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

what happens if arrays of different lengths are added

A

will produce an error as they can’t be added

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

what are scalars

A

constants

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

how do scalars operate on arrays

A

perform the operation on each element separately

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

unsigned integers vs integers

A

unsigned integers stores only positive numbers and zero
integers store all numbers positive and negative

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

what does U10 mean? break it down

A

U indicates names are stored as “unicode strings”
10 signifies names won’t be longer than 10 characters

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

what does np.zeros do

A

creates a matrix of all zeroes

17
Q

what does np.ones do

A

creates a matrix of all ones

18
Q

what does np.eyes do

A

creates an identity matrix

19
Q

what does np.arrange do

A

create a loop

20
Q

what does np.linspance do

A

creates a number of values, evenly spaced from start to end

21
Q

what does np.count_nonzero() do

A

counts how many elements in an array are non-zero

22
Q

what does np.all do

A

a yes/no which tells is whether all records meet a specific condition

23
Q

what does np.any do

A

a yes/no that tells us if there are any records that meet a certain condition

24
Q

what does np.sum do

A

sum of entire array

25
np.amin and np.amax??
smallest/largest array value
26
np.dot
multiplication
27
np.where
returns indices over a point