A Local Variable Is Defined

Question: A group of statements that exist within a program for the purpose of performing a specific
task is a(n) __________.
Answer: function
==================================================
Question: A design technique that helps to reduce the duplication of code within a program and
is a benefit of using functions is __________.
Answer: code reuse
==================================================
Question: The first line of a function definition is known as the __________.
Answer: header
==================================================
Question: You __________ the function to execute it.
Answer: call
==================================================
Question: A design technique that programmers use to break down an algorithm into functions
is known as __________.
Answer: top-down design
==================================================
Question: A __________ is a diagram that gives a visual representation of the relationships
between functions in a program.
Answer: hierarchy chart
==================================================
Question: A __________ is a variable that is created inside a function.
Answer: local variable
==================================================
Question: A(n) __________ is the part of a program in which a variable may be accessed.
Answer: scope
==================================================
Question: A(n) __________ is a piece of data that is sent into a function.
Answer: argument
==================================================
Question: A(n) __________ is a special variable that receives a piece of data when a function is called.
Answer: parameter
==================================================
Question: A variable that is visible to every function in a program file is a __________.
Answer: global variable
==================================================
Question: When possible, you should avoid using __________ variables in a program.
Answer: global
==================================================
Question: The phrase "divide and conquer" means that all of the programmers on a team should
be divided and work in isolation.
Answer: F
==================================================
Question: Functions make it easier for programmers to work in teams.
Answer: T
==================================================
Question: Function names should be as short as possible.
Answer: F
==================================================
Question: Calling a function and defining a function mean the same thing.
Answer: F
==================================================
Question: A flowchart shows the hierarchical relationships between functions in a program.
Answer: F
==================================================
Question: A hierarchy chart does not show the steps that are taken inside a function.
Answer: T
==================================================
Question: A statement in one function can access a local variable in another function.
Answer: F
==================================================
Question: In Python you cannot write functions that accept multiple arguments.
Answer: F
==================================================
Question: In Python, you can specify which parameter an argument should be passed into a function
call.
Answer: T
==================================================
Question: You cannot have both keyword arguments and non-keyword arguments in a function call.
Answer: F
==================================================
Question: How do functions help you to reuse code in a program?
Answer: Functions help you reuse code in a program because the function can be written once to perform an operation, and then be executed any time it is needed.
==================================================
Question: Name and describe the two parts of a function definition.
Answer: The two parts of a function definition are known as a function header and a block. The header marks the beginning of the function definition and begins with the keyword 'def' followed by the name of the function, followed by a set of parenthesis, and followed by a colon. The block is a set of statements that belong together as a group, and are performed any time the function is executed.
==================================================
Question: When a function is executing, what happens when the end of the function block is
reached?
Answer: When a function is executing, it 'returns' when the end of the block is reached - meaning the interpreter jumps back to the part of the program that called the function, and the program resumes execution at that point.
==================================================
Question: What is a local variable? What statements are able to access a local variable?
Answer: A local variable is a variable that is declared inside of a function. Only statements in the same function can access a local variable.
==================================================
Question: What is a local variable's scope?
Answer: A local variable's scope is the part of a program in which the variable may be accessed and is only visible to the statements in the variable's scope.
==================================================
Question: Why do global variables make a program difficult to debug?
Answer: Global variables make a program difficult to debug because any statement in a program file can change the value of a global variable. If you find that the wrong value is being stored in a global variable, you have to track down every statement that accesses it to determine where the bad value is coming from.
==================================================