Free Online Flashcard Deck

5 Functions and Program Structure Free Online FlashCards

Study 5 Functions and Program Structure with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a function?

Back

Functions are named, reusable sections of a program that perform a focused task. They reduce repetition and make code easier to understand, test, and maintain.

02
Front

What are the main parts of a function?

Back

A function usually has a name, parameters, a body containing instructions, and a return value when it produces a result.

03
Front

How does a definition differ from a call?

Back

A function definition creates the function; a function call runs it. In Python, the `def` statement introduces a function definition.

04
Front

What is the difference between a parameter and an argument?

Back

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

05
Front

How does returning differ from printing?

Back

`return` sends a value back to the caller, where it can be stored, displayed, compared, or passed to another function. `print` only displays a value.

06
Front

What does Python return without an explicit `return`?

Back

In Python, reaching the end of a function without an explicit `return` produces `None`. A function with no useful result therefore still technically returns a value.

07
Front

What does scope determine?

Back

Scope is the region where a name can be accessed. A local variable normally exists only inside its function, while a global variable is defined at program or module level.

08
Front

How do local variables support encapsulation?

Back

Encapsulation keeps a function's internal state isolated through local variables. This helps prevent unrelated parts of a program from changing that state accidentally.

09
Front

What does a function interface specify?

Back

A function's interface includes its name, accepted parameters, possible values or errors, and important side effects such as writing a file or changing a database.

10
Front

What do cohesion and coupling mean?

Back

High cohesion means a module contains closely related responsibilities. Low coupling means modules depend on one another as little as practical.

11
Front

What is function decomposition?

Back

Function decomposition breaks a larger problem into focused tasks, gives each task a function, defines its data flow, connects the functions, and tests them independently before testing the whole program.

12
Front

Why is code reuse valuable?

Back

Code reuse means calling an existing function or module instead of rewriting the same algorithm. It reduces duplication and helps corrections apply consistently.