Programming Flashcards
Does git copy your entire directory each time you commit?
No, it usually only stores the delta from the previous version (if possible)
Why can the use of git log turn into a vicious cycle?
Unstructured commit messages means fewer people bother to use git log, meaning that fewer people care to write proper commits, and so on.
What is a leaf node?
A node without children.
How should you name classes and methods?
Classes should be nouns, methods should be verbs.
Why can it make sense to describe a function with a “TO paragraph”?
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.
What does API stand for?
Application Programming Interface
What does -> mean in a Python function declaration?
It marks the return function annotation (which, for example, could be a description of what type, or which SI units, one expects to return)
What is a nested function, and when can it make sense to use it?
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 to reset git back to last commit
git reset –hard
What are keys in a Python dictionary?
Whatever you have to write to unlock the values. Syntax: dict = {“key” : values}
What is an attribute (in Python)?
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)
What is a static method (in Python)?py
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