Midterm 2 Cheat Sheet
Midterm 2 Cheat Sheet
A continue statement in a loop causes an immediate jump to the while or for loop header statement.
A loop may optionally include an else clause that executes only if the loop terminates normally
A function with no return statement, or a return statement with no following expression, returns the
value None. None is a special keyword that indicates no value.
A function with no return statement is called a void function, and such a function returns the
value None.
The function's behavior of being able to add together different types is a concept called polymorphism.
Python uses dynamic typing to determine the type of objects as a program executes. In contrast to
dynamic typing, many other languages like C, C++, and Java use static typing, which requires the
programmer to define the type of every variable and every function parameter in a program's source
code.
Modular development is the process of dividing a program into separate modules that can be
developed and tested separately and then integrated into a single program.
Improving program readability
Avoid writing redundant code
Programs are typically written using incremental development, meaning a small amount of code is
written and tested, then a small amount more (an incremental amount) is written and tested, and so on.
To assist with the incremental development process, programmers commonly introduce function stubs,
which are function definitions whose statements haven't been written yet.
part of the value of a function object is compiled bytecode that represents the statements to be
executed by the function.
A variable or function object is only visible to part of a program, known as the object's scope
A namespace maps names to objects. The Python interpreter uses namespaces to track all of the objects
in a program. Maps the visible names in a scope to objects.
If the name cannot be found in any namespace, the interpreter generates a NameError. The process of
searching for a name in the available namespaces is called scope resolution
A docstring is a string literal placed in the first line of a function body. A docstring starts and ends with
three consecutive quotation marks.
The help() function can aid a programmer by providing them with all the documentation associated with
an object.