functions Flashcards
a group of statements that exist within a program for the purpose of performing a specific task is a …….
function
a design technique that helps to reduce the duplication of code within a program is ……..
code reuse
the first line of a function is known as the ………
header
you ……. a function to execute it
call
a design technique that programmers use to break down an algorithm into functions is known as …….
top-down design
a ……. is a diagram that gives a visual representation of the relationships between functions in a program
hierarchy chart
a ……… is a variable that is created inside a function
local variable
a ……… is the part of a program in which a variable may be accessed
scope
an ………. is a piece of data that is sent into a function
argument
a ………… is a special variable that receives a piece of data when a function is called
parameter
a variable that is visible to every function in a program file is a ……..
global variable
when possible you should avoid using …….. variables in a program
global
library function
this is a pre-written function that is built into a programming language
‘random()’
this standard library function returns a random integer within a specified range of values
and/or
this standard library function returns a random floating-point number in the range of 0.0 up to but not including 1.0
‘uniform()’
this standard library function returns a random floating-point number within a specified range of values
‘return’
this statement causes a function to end and sends a value back to the part of the program that called the function
datagram chart
this is a design tool that describes the input, processing and output of a function
Boolean
this type of function returns true or false
differentiate
this is a maths module function
How do functions help you to reuse code in a program?
They let you perform the same operations over and over without having to retype every line of the implementation.
Name and describe the two parts of a function definition.
The header is the first line of a function definition and it defines the name and any parameter variables. The body defines what the function does.
When a function is executing, what happens when the end of the function block is reached?
At the end of the function block, the program goes back to the place where the function was called and continues executing statements from that point. Using the standard nomenclature, we say that control returns to the point that the function was called.
What is a local variable? What statements are able to access a local variable?
A local variable is a variable that is defined inside a function block without the global keyword. The only statements that are able to access a local variable are those that come after it within the same function block.
What is a local variable’s scope?
everywhere below the point the variable is defined that is within the same function as the variable