A variable is like a box that can hold one value at a time, such as one word, one costume, or one list (which can contain many things). You can look at what's inside as many times as you want.
A local variable can be set or used only in the environment in which it is defined. This term includes inputs to procedures and variables created by the for
or script variables
block.
The word Boolean is capitalized because it's named after a person, George Boole, who invented the branch of mathematics dealing with Boolean operations (such as and
, or
, and not
).
A predicate is a hexagon-shaped reporter that asks a true/false question such as these examples:
Predicates report a Boolean value (either or
).
The if
and if-else
blocks are called conditionals because they control the code based on a true-or-false condition.
A global variable is a variable that is usable by all scripts in the program.
The position number is called the index of the item in the list.
In this list, 1 is the index of the item "apple," 2 is the index of the item "cantaloupe," and so on.
In Snap! and on the AP exam, the index is always a whole number (1, 2, 3, 4, etc.). It is an error to use an index less than 1 or greater than the length of the list.
An element is another name for an item in a list. (If the same value is in the list twice, that counts as two different elements.) Each element has a unique index (position) in the list.
A sublist is a list used as an item of another list.
(The word sublist is also used to refer to some subset of a list.)
The word "abstract" is often used casually to mean something harder to understand or more complex, but in computer science, its meaning is almost the opposite. ADTs are things that you, the programmer, create to make your program easier for you and others to read, debug, and improve.
quiz item
has to think only about questions and answers, not about list indices.
quiz item
abstract data type.
A table is a two-dimensional data structure with rows and columns. If you've used a spreadsheet program, what it displays is a table.
In Snap!, a table is implemented as a list of lists, in which each sublist is one row of the table.
Using the result from item
as the input to address from contact
is called composition of functions.
Traversing a list means looking at each item of the list. For each
is iterative. That is, it's repetitive, like for
, which can also traverse a list. But unlike for
, for each
traverses the list without using index numbers.
Selection means deciding (selecting) which part of an algorithm to run based on whether a condition is true or false.
Every algorithm can be constructed using sequencing (following steps in order), selection (deciding), and iteration (repeating).
A nested conditional statement is an if
or if else
statement inside another if else
statement.
letter
is the index.An application program interface (API) documents what a programmer needs to know about using a library: it's a description of each procedure's purpose, inputs, and outputs (but not its algorithms).
A common kind of API is a web API in which the library exists on someone else's computer. For example, the Google Maps API describes how to embed a Google Map on your own website.
A web API is just a call to a procedure on another machine. For example, these are three different notations for the same procedure call, which looks up the number of searches for "BJC" in the US:
EXPLORE (q = BJC, geo = US)
Ideas similar to Creative Commons are used for particular kinds of material: