Programming Flashcards

1
Q

Does git copy your entire directory each time you commit?

A

No, it usually only stores the delta from the previous version (if possible)

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

Why can the use of git log turn into a vicious cycle?

A

Unstructured commit messages means fewer people bother to use git log, meaning that fewer people care to write proper commits, and so on.

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

What is a leaf node?

A

A node without children.

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

How should you name classes and methods?

A

Classes should be nouns, methods should be verbs.

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

Why can it make sense to describe a function with a “TO paragraph”?

A

Functions should do one thing - at one level of abstraction - and if you can describe it in a very brief paragraph starting with “To”, you may be on the right track.

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

What does API stand for?

A

Application Programming Interface

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

What does -> mean in a Python function declaration?

A

It marks the return function annotation (which, for example, could be a description of what type, or which SI units, one expects to return)

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

What is a nested function, and when can it make sense to use it?

A

It’s a function defined inside a function. Usually, this slows down the code and is not a good idea. But in some cases, if you want to vary the nested function’s definition each time it’s called, using nested functions may be a good idea.

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

How to reset git back to last commit

A

git reset –hard

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

What are keys in a Python dictionary?

A

Whatever you have to write to unlock the values. Syntax: dict = {“key” : values}

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

What is an attribute (in Python)?

A

A variable stored in a class (technically, some may claim that methods can also be attributes, but it’s probably most fruitful to think about it as variables)

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

What is a static method (in Python)?py

A

A method bound to the class rather than the object for that class, implying:

  • that static methods can be called without an object of a class
  • and consequently, that static functions cannot modify the state of an object, as they are not bound to it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly