Glossary
AP Pseudocode
A standardized, language-independent notation used in the AP Computer Science Principles exam to represent algorithms and programming concepts.
Example:
The structure PROCEDURE example(val) { RETURN val * 2 }
is written in AP Pseudocode.
Arguments
The actual values or expressions passed to a procedure when it is called, which are assigned to the corresponding parameters.
Example:
When you call calculate_discount(100, 0.15)
, 100
and 0.15
are the arguments being sent to the procedure.
Calling a Procedure
The action of executing the code defined within a procedure by referencing its name and providing any required arguments.
Example:
After defining a procedure display_greeting()
, you perform calling a procedure by simply writing display_greeting()
in your code.
Parameters
Variables listed in a procedure's definition that act as placeholders for the input values the procedure expects to receive.
Example:
In PROCEDURE calculate_discount(price, percentage)
, price
and percentage
are the parameters that define what information the procedure needs.
Procedure
A self-contained block of code designed to perform a specific task, often referred to as a method or function in different programming languages.
Example:
You could create a procedure called draw_square
that contains all the steps to draw a square, making your main program cleaner.
RETURN Statement
A command used within a procedure to specify the value that the procedure will send back to the calling program and to terminate the procedure's execution.
Example:
Inside a procedure that finds the maximum of two numbers, RETURN max_num
would send the largest number back to where the procedure was called.
Return Value
The result or output that a procedure sends back to the part of the program that called it after completing its execution.
Example:
A procedure that converts Fahrenheit to Celsius would have the calculated Celsius temperature as its return value.
Reusability
The principle of writing code once and being able to use it multiple times throughout a program or in different programs, often achieved through procedures.
Example:
Instead of writing the same complex calculation three times, you can put it into a single procedure, demonstrating excellent code reusability.
Variable Scope
The region of a program where a variable is accessible and can be used, typically limited to the block of code where it was defined.
Example:
A variable declared inside a procedure has a local variable scope, meaning it cannot be directly accessed or modified from outside that procedure.