Free Online Flashcard Deck

06. Procedures and Functions Free Online FlashCards

Study 06. Procedures and Functions with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is the difference between a function definition and a function call?

Back

A function definition describes a routine; a function call executes its body with particular argument values. Defining a function normally does not run its body immediately.

02
Front

How do parameters differ from arguments?

Back

A parameter is a variable in a function definition; an argument is the actual value supplied when the function is called.

03
Front

What does a return statement do?

Back

return sends a result back to the calling code and ends the current function call. Statements after an executed return are not run.

04
Front

What does Python return when a function ends without a value?

Back

If a Python function reaches its end without returning a value, it returns None.

05
Front

How do positional and default arguments work?

Back

Positional arguments normally match parameters in order. A default parameter value is used when that argument is omitted, as with exponent=2 in power(5).

06
Front

What is local-variable scope?

Back

Scope is the region where a name can be accessed. A variable created inside a function is usually local to that function call and cannot normally be accessed directly outside it.

07
Front

Why should functions minimize dependence on global variables?

Back

Passing required data as parameters and returning results explicitly makes a function’s dependencies visible. Heavy reliance on global variables makes programs harder to test and understand.

08
Front

What is a side effect?

Back

A side effect changes something outside the function, such as printing output, modifying a shared list, changing a file, or updating a user interface.

09
Front

What characterizes a pure function?

Back

A pure function depends only on its parameters and returns a result without changing outside state. The same inputs produce the same output.

10
Front

What is decomposition in programming?

Back

Decomposition divides a large problem into smaller subproblems, each handled by a function with a clear responsibility.

11
Front

What does function abstraction provide?

Back

An abstraction hides implementation details behind a simpler interface. Users need the function’s name, inputs, and result rather than every statement inside it.

12
Front

What qualities make a function useful?

Back

A useful function has a focused purpose, descriptive name, clear parameters, a predictable return value or side effect, and minimal hidden global-state dependence.