Python Flashcards

1
Q

What are the two modes you can run Python on?

A

Standard and interactive mode.

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

What environments does Anaconda uses?

A

Jupyter and Spyder

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

What are the three charactestic of each object in Python:

A

1) Type: determines the operations it can support
2) Value
3) Identity: an identity number for the object.

Each object has attributes (separated by dot, data attribute (value) or methods (functions)).

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

What is an instance?

A

An occurrence of an object

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

x.shape: (a data attribute)

A

Give you the amount of elements in an array.

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

How do you distinguish from data attribute and method?

A

Method is followed by parentheses x.mean()

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

What happens when you run the import statement

A

1) Create a new namespace for all the objects in the module
2) Execute the code of the module and run it in the new namespace
3) Creates a name for referencing the new namespace.

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

dir(str):

A

Give the list of methods for the object in question

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

True or False

A

True

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

True and False

A

False

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

What is a sequence in python?

A

A collection of objects in order (list, tuple, range)

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

Why are list methods “In place” methods?

A

They modify the original list, they do not return a new list.

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

What is polymorphism in python?

A

The operator ouput depends on the type of object it is applied to (think addition between string vs addition between numbers, a plus sign between string means concatenation).

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

What is the span of a pair of vector?

A

It is the set of all their linear combinations.

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

What does it mean that two or three vectors are linearlydependent?

A

One of them is redudant, you could remove one of them without reducing the span of the vectors (in other word they are sitting on the same line or on the same plane in 3D)

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

What are the two properties of a linear transformation?

A

All lines must remain lines and the origin must remain fixed in space. It maintains grid lines parallel and evenly spaced.

17
Q

What are the two kinds of copies?

A

1) Shallow
2) Deep (also create the copy of the objects and references to the objects)

18
Q

List the statements:

A

Return
Import
Pass

19
Q

What are compounds statement?

A

Contains other statements and control their execution, span multiple lines. They consist of one or more clauses and a block (or suited) indented code that fall under the header.

20
Q

What is a unit vector?

A

It is a vector with all elements equal to zero, except one element which is equal to one.

21
Q

What is a sparse vector?

A

A vector is said to be sparse if many of its entries are zero; its sparsity pattern is the set of indices of nonzero entries

22
Q

What is the sum of two vectors?

A

Two vectors of the same size can be added together by adding the corresponding
elements, to form another vector of the same size, called the sum of the vectors.
Vector addition is denoted by the symbol +.

23
Q

What are universal function in numpy?

A

A universal function, or ufunc, is a function that performs element-wise operations on data in ndarrays. You can think of them as fast vectorized wrappers for simple functions that take one or more scalar values and produce one or more scalar results.

Many ufuncs are simple element-wise transformations, like numpy.sqrt or numpy.exp.

These are referred to as unary ufuncs. Others, such as numpy.add or numpy.maximum, take two arrays (thus, binary ufuncs) and return a single array as the result.

24
Q

What is vectorization?

A

This practice of replacing explicit loops with array expressions is referred to by some people as vectorization.