What is a function?
A group of statements in a program that perform a specific task
What is modularization in programming?
Breaking a program into functions so each task is in its own function
What are the benefits of using functions?
Simpler code, code reuse, easier testing/debugging, faster development, and easier teamwork
What is a void function?
A function that executes its statements and then terminates without returning a value
What is a value-returning function?
A function that executes statements and returns a value to the caller
What are the rules for naming functions in Python?
Cannot be a keyword, no spaces, must start with a letter/underscore, can include letters/digits/underscores, case sensitive
What is a function definition?
Code that specifies what a function does, starting with a header and containing a block of statements
What is a function header?
The first line of a function: starts with def, includes the function name, parentheses, and a colon
What is the main function?
The function that defines the mainline logic of the program and calls other functions
What is the pass keyword used for in functions?
To create an empty placeholder function
What is a local variable?
A variable assigned inside a function; it can only be accessed within that function
What is the scope of a local variable?
Limited to the function in which it is created
What is an argument?
A piece of data sent into a function
What is a parameter?
A variable inside a function that receives the value of an argument
How are multiple arguments passed to functions?
By position; the first argument matches the first parameter, and so on
What does “pass by value” mean in Python functions?
Changes made to parameters inside a function do not affect the original arguments
What is a keyword argument?
An argument that specifies which parameter it corresponds to using parameter=value
What are keyword-only parameters?
Parameters that must be passed using keyword arguments (declared after * in the parameter list)
What are positional-only parameters?
Parameters that only accept positional arguments (declared before / in the parameter list)
What is a default argument?
A parameter with a predefined value that is used if no argument is passed
What is a global variable?
A variable declared outside all functions, accessible from anywhere in the program
Why should global variables generally be avoided?
They make debugging harder, reduce portability, and make programs harder to understand
What is a global constant?
A global name that references a value that should never change
What is the difference between a void function and a value-returning function?
Void executes code and ends; value-returning executes code and sends a value back