Free Online Flashcard Deck

06 Methods and Modular Programming Free Online FlashCards

Study 06 Methods and Modular Programming with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a method?

Back

A method is a named, reusable block of code that performs a specific task.

02
Front

What does a method definition contain?

Back

A method definition normally includes a name, parameters, and a body; it may also specify a return value.

03
Front

What is a parameter?

Back

A parameter is a named variable in a method definition, such as `name` in `def greet(name)`.

04
Front

What is an argument?

Back

An argument is the actual value supplied when a method is called, such as `"Maya"` in `greet("Maya")`.

05
Front

What does a return value do?

Back

A return value is a result sent from a method back to the code that called it.

06
Front

How does returning differ from printing?

Back

Printing displays information immediately, while returning makes the result available to the calling code for later use.

07
Front

What is a local variable?

Back

A local variable is normally accessible only within the method where it is created.

08
Front

What is a method call?

Back

A method call, or invocation, asks the program to execute a method with particular arguments.

09
Front

What does `add(7, 4)` return?

Back

`sum_value` stores `11`: `add(7, 4)` assigns the arguments to `first` and `second`, then returns their sum.

10
Front

What is recursion?

Back

Recursion occurs when a method calls itself. Every recursive method needs a base case to stop the repeated calls.

11
Front

What is decomposition in programming?

Back

Decomposition divides a complex problem into smaller subproblems, often implemented as focused methods.

12
Front

Why decompose a program into methods?

Back

Focused decomposition improves clarity, allows independent testing, supports reuse, simplifies maintenance, and helps isolate bugs.