Chapter 5 Key Terms Flashcards
Function
A block of code that performs a certain task or set of tasks.
Divide and Conquer
Breaking down a problem into smaller problems that can be solved. Then combining the solutions to solve the initial problem. Functions can be executed in order.
Benefits of Using Functions
Benefits include a much simpler code, reusable code, effective testing and debugging, faster development, and easier teamwork when writing codes.
Void Functions
Executes the statements it contains, then terminates.
Value-Returning Functions
Executes the statements it contains, and returns a value back to the statement that called it.
Function Names
Names cannot contain keywords or spaces. The first character has to either be a letter or underscore. Other characters must be a letter, number or underscore. The uppercase and lowercase characters are distinct.
Function Definition
Determines what that function does.
Function Header
The first line of the function
Block
A set of statements that belong together as a group.
Function Call
A way to execute a specific block of code defined within a function. The interpreter jumps to the function and executes the statement.
Indentation and Functions
Each block needs to be indented and the lines must start with the same number of spaces.
pass
Used as a placeholder statement that does nothing when executed.
Local Variables
Variable that is given a value inside a function.
Variable Scope
The part of a program where the variable may be accessed.
Argument
The data that is sent into a function.
Parameter
The variable that is given the value of an argument when a function is called.
Parameter Scope
The function in which the parameter is used.
Passed by Position
The first parameter gets the value of the first argument and the second parameter gets the value of the second argument.
Global Variable
Created by assignment statement written outside all the functions.
Global Constant
Global name that references a value that cannot be changed.
import Statement
Statements that are used to include modules.
random
Module is a standard library module that provides functions for generating random numbers and performing operations.
return Statement
Statement used within a function to specify the value that the function should produce as a result when it’s called.
None
Constant that represents the absence of a value or a null value.
math
Module that provides a wide range of mathematical functions and constants for performing various mathematical operations.
math.pi
Represents the mathematical constant π (pi).
math.e
Represents the mathematical constant e (Euler’s number).
Module
Files that stores functions of the standard library.