Chapter 5, Part 1 Flashcards
Function
Group of statements within a program that perform a specific task.
Modularized program
Program wherein each task within the program is in its own function
Void function
Executes the statements it contains and then terminates
Value-returning function
Executes the statement it contains and then returns a value back to the statement that called it. The input(), float() and int() functions are examples of vale-returning functions.
Function definition
Specifies what the function does
def function_name() :
statement
statement
Function header
The first line of the function. Includes def and function_name, followed by parentheses and colon
Block
Set of statements that belong together as a group
Main function
Function called when the program starts
Top-down design
Technique for breaking down algorithms into functions.
Hierarchy chart
Depicts relationships between functions.
Local variable
Variable that is assigned a value inside a function.
Scope
The part of a program in which the variable may be accessed.
Argument
Piece of data that is sent into a function
Parameter variable
Variable that is assigned the value of the argument when the function is called. Or, a parameter is a variable that receives an argument that is passed into a function.
Scope of parameter
The function in which the parameter is used.
Global variable
Created by assignment statement written outside all of the functions.
Global constant
Global name that references a value that cannot be changed.
Lifetime
For how long the variable is “alive”. For a local variable, that is for one execution of the function. For a global variable, that is for as long as the program is running.