Composing Programs One Flashcards
What do we need to define a computational process?
A programming language.
What are 2 uses of a programming language?
A means for instructing computers to perform tasks and a framework in which we organise ideas about computational processes.
What are 3 mechanisms a programming language has for combining simple ideas to form more complex ones?
Primitive expressions/statements, means of combination(building) and means of abstraction(naming).
What are two kinds of elements we deal with in programming?
Functions and data.
Informally, what is data?
Stuff we want to manipulate.
Informally, what does a function do?
They describe the rules for manipulating data.
Name a primitive expression.
Number
Describe infix notation in an expression.
The operator appears between the operands.
What is the most important type of compound expression?
A call expression, which applies a function to some arguments.
What are three reasons function notation is better than infix notation?
Functions can take an arbitrary number of arguments, for ambiguity can arise because the function name always precedes its arguments. Function expression extends in a straightforward way to nested expressions. Some of the notation can be difficult to type.
What comprises the Python library?
Modules.
What is in a module?
Functions and other quanitities.
If a value has been given to a name, what do we say about the relation to the value and the name?
We say the name binds to the value.
How we do establish new bindings?
With the assignment statement (=).
Name another way names are bound.
With the import statement.
What is assignment an example of?
Abstraction, for it allows us to use simple names to refer to the results of compound operations
What is an environment?
A memory that keeps track of names, values and bindings.
What is another name for names in Python?
Variables, because they can be bound to different values in the course of executing a program.
What is the interpreter doing when it evaluates nested call expressions?
Following a procedure
Name the two steps Python does to evaluate a call expression? And what is this procedures nature?
- Evaluate the operator and operand subexpressions, then
- apply the function that is the value of the operator subexpression to the arguments that are the values of the operand subexpressions.
Recursive
What are the objects at each point in a tree called?
Nodes
What direction do trees grow from?
The top down