PracticalStuff Flashcards

1
Q

Help on the len function

A

len?, len??

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

Create a docstring

A

Place a string literal in the first line

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

sometimes the ?? suffix doesn’t display any source code

A

T object in question is not implemented in Python, but in C or ..

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

List every object in the namespace that ends with Warning

A

*Warning?

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

Find a string method that contains the word find somewhere in its name.

A

str.find?

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

Make a list of the first 1000 squares, timing it.

A

%timeit L = [n ** 2 for n in range(1000)]

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

Time steps in a for-loop:

A

%%timeit
…: L = []
…: for n in range(1000):
…: L.append(n ** 2)

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

Side-by-side subplots:

A

plt.subplot(221)
p1=plt.hist(ldh_vals.ord_num_value,bins=20,log=False)
plt.subplot(222)
p2=plt.hist(ldh_vals.ord_num_value,bins=20,log=True)
plt.show()

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

List of all magic functions

A

%lsmagic

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

Help on %timeit

A

%timeit?

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

List the IPython lines so far:

A

print(In)

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

List the Cell outputs so far

A

print(Out)

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

You execute two very expensive computations in cells 2 and 3. You want to the results of 2 and 3.

A

Out[2] ** 2 + Out[3] ** 2

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

Accessing previous output,

the second-to-last output, to access the third-to-last output

A

_
__
___

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

Suppress the output of a command is to

A

add a semicolon to the end
In [14]: math.sin(2) + math.cos(2);
result is computed silently, and the output is neither displayed on the screen or stored in the Out dictionary:

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