CIS115 - Chapter 3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

How do functions help you to reuse code in a program?

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.

You __________ the function to execute it.

call

A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is __________.

code reuse

A design technique that programmers use to break down an algorithm into functions is known as __________.

top-down design

Why do global variables make a program difficult to debug?

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.

A group of statements that exist within a program for the purpose of performing a specific task is a(n) __________.

function

When possible, you should avoid using __________ variables in a program.

global

A variable that is visible to every function in a program file is a __________.

global variable

The first line of a function definition is known as the __________.

header

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(n) __________ is a special variable that receives a piece of data when a function is called.

parameter

A(n) __________ is the part of a program in which a variable may be accessed.

scope

Functions make it easier for programmers to work in teams.

T

What is a local variable? What statements are able to access a local variable?

A local variable is a variable that is declared inside of a function. Only statements in the same function can access a local variable.

What is a local variable's scope?

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.

A flowchart shows the hierarchical relationships between functions in a program.

F

A statement in one function can access a local variable in another function.

F

Calling a function and defining a function mean the same thing.

F

Function names should be as short as possible.

F

In Python you cannot write functions that accept multiple arguments.

F

The phrase "divide and conquer" means that all of the programmers on a team should be divided and work in isolation.

F

You cannot have both keyword arguments and non-keyword arguments in a function call.

F

A hierarchy chart does not show the steps that are taken inside a function.

T

In Python, you can specify which parameter an argument should be passed into a function call.

T

Name and describe the two parts of a function definition.

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.

When a function is executing, what happens when the end of the function block is reached?

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.

A(n) __________ is a piece of data that is sent into a function.

argument


Ensembles d'études connexes

4. Connective Tissue Cells: General & Fibroblasts

View Set

Chemical vs. Mechanical Digestion

View Set

CITI Trainings: RCR & Authorship

View Set

Chapter 2: Marketing Strategy (Company)

View Set

CISS 120 - Module 5: Number Systems

View Set

Chapter 8: Risk, Response, and Recovery

View Set

Completing the Application, Underwriting, and Delivering the Policy

View Set