AP Computer Science Principles Flashcards: Calling Procedures

Study Calling Procedures in AP Computer Science Principles with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

AP Computer Science Principles

Calling Procedures

0 mastered0 still learning

0% Complete

QUESTION
1/ 48

What is a procedure in programming?

Tap card or press Space to flip

ANSWER

A named section of code that performs a specific task. Code blocks enable reusability and modularity.

How well did you know it?

Card 1 / 48

What this deck covers

This deck focuses on Calling Procedures, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

All flashcards

Flashcard 1: What is a procedure in programming?

Answer: A named section of code that performs a specific task. Code blocks enable reusability and modularity.

Flashcard 2: What is a function signature?

Answer: Function name and parameter list. Identifies the procedure and its expected inputs.

Flashcard 3: What is the term for executing a procedure?

Answer: Calling a procedure. Invokes the procedure to run its code.

Flashcard 4: What is a method in object-oriented programming?

Answer: A procedure associated with a class/object. Function bound to a specific class instance.

Flashcard 5: What does 'pass by reference' mean?

Answer: Parameters refer to argument locations. Changes to parameters affect original variables.

Flashcard 6: What does 'void' mean in procedure context?

Answer: Procedure does not return a value. Procedures that perform actions without output.

Flashcard 7: Identify the part of a procedure that specifies input.

Answer: Parameters. Parameters define what inputs the procedure expects.

Flashcard 8: Identify the error: 'def foo(x, y=3, z): return x + y + z'

Answer: Non-default parameter 'z' after default 'y'. Required parameters cannot follow optional ones.

Flashcard 9: Which part of a procedure specifies its output?

Answer: Return value. What the procedure sends back to the caller.

Flashcard 10: Identify the error in: 'def add(x, y): return x + y; print(add(3))'

Answer: Missing one argument in 'add(3)'. Function expects two arguments but only receives one.

Flashcard 11: What is the scope of a parameter?

Answer: Within the procedure where it is defined. Parameters only exist within their procedure's execution.

Flashcard 12: Identify the error: 'def example(a, b): return a * b; example(2)'

Answer: Missing one argument in 'example(2)'. Two parameters required but only one provided.

Flashcard 13: How are procedures beneficial in programming?

Answer: They promote code reuse and organization. Avoid code duplication and improve maintainability.

Flashcard 14: State whether procedures can have default parameter values.

Answer: Yes. Default values provide flexibility in procedure calls.

Flashcard 15: What is a method in object-oriented programming?

Answer: A procedure associated with a class/object. Function bound to a specific class instance.

Flashcard 16: Find and correct the error: 'def myFunc(x, y) return x + y'

Answer: Correct: 'def myFunc(x, y): return x + y'. Missing colon after parameter list in function definition.

Flashcard 17: Identify the part of a procedure that specifies input.

Answer: Parameters. Parameters define what inputs the procedure expects.

Flashcard 18: Find the error: 'def greet(name): return print('Hello', name)'

Answer: Remove 'return' before 'print'. Cannot return a function call that returns None.

Flashcard 19: What is a procedure in programming?

Answer: A named section of code that performs a specific task. Code blocks enable reusability and modularity.

Flashcard 20: What does 'void' mean in procedure context?

Answer: Procedure does not return a value. Procedures that perform actions without output.

Flashcard 21: Find and correct the error: 'def myFunc(x, y) return x + y'

Answer: Correct: 'def myFunc(x, y): return x + y'. Missing colon after parameter list in function definition.

Flashcard 22: Identify the error: 'def func(x=1, y): return x + y'

Answer: Non-default parameter 'y' after default 'x'. Required parameters must come before defaults.

Flashcard 23: Choose the correct term: 'void' procedures return a value?

Answer: False. Void procedures perform actions without returning values.

Flashcard 24: What is recursion in procedures?

Answer: Procedure calls itself. Enables solving problems by breaking them down.

Flashcard 25: Identify the error: 'def add(a, b): print(a + b)' when expecting return.

Answer: Missing return statement. Function prints but doesn't return the sum value.

Flashcard 26: What is modularity in programming?

Answer: Dividing a program into separate modules. Breaks complex problems into manageable components.

Flashcard 27: Choose the correct term: 'void' procedures return a value?

Answer: False. Void procedures perform actions without returning values.

Flashcard 28: What is returned if a procedure lacks a return statement?

Answer: Typically, 'None' or equivalent. Default return when no explicit return statement exists.

Flashcard 29: How are procedures beneficial in programming?

Answer: They promote code reuse and organization. Avoid code duplication and improve maintainability.

Flashcard 30: Identify the error: 'def add(a, b): print(a + b)' when expecting return.

Answer: Missing return statement. Function prints but doesn't return the sum value.

Flashcard 31: What is modularity in programming?

Answer: Dividing a program into separate modules. Breaks complex problems into manageable components.

Flashcard 32: What is a parameter's role in a procedure?

Answer: To receive arguments as input. Acts as placeholder for values passed during calls.

Flashcard 33: Identify the error in: 'def add(x, y): return x + y; print(add(3))'

Answer: Missing one argument in 'add(3)'. Function expects two arguments but only receives one.

Flashcard 34: Find the error: 'def greet(name): return print('Hello', name)'

Answer: Remove 'return' before 'print'. Cannot return a function call that returns None.

Flashcard 35: What is the term for executing a procedure?

Answer: Calling a procedure. Invokes the procedure to run its code.

Flashcard 36: What does 'pass by value' mean?

Answer: Arguments are copied into parameters. Original values remain unchanged in calling code.

Flashcard 37: What does 'pass by reference' mean?

Answer: Parameters refer to argument locations. Changes to parameters affect original variables.

Flashcard 38: Identify the error: 'def func(x=1, y): return x + y'

Answer: Non-default parameter 'y' after default 'x'. Required parameters must come before defaults.

Flashcard 39: What is returned if a procedure lacks a return statement?

Answer: Typically, 'None' or equivalent. Default return when no explicit return statement exists.

Flashcard 40: What is the scope of a parameter?

Answer: Within the procedure where it is defined. Parameters only exist within their procedure's execution.

Flashcard 41: What does 'pass by value' mean?

Answer: Arguments are copied into parameters. Original values remain unchanged in calling code.

Flashcard 42: What is recursion in procedures?

Answer: Procedure calls itself. Enables solving problems by breaking them down.

Flashcard 43: What is a function signature?

Answer: Function name and parameter list. Identifies the procedure and its expected inputs.

Flashcard 44: State whether procedures can have default parameter values.

Answer: Yes. Default values provide flexibility in procedure calls.

Flashcard 45: Which part of a procedure specifies its output?

Answer: Return value. What the procedure sends back to the caller.

Flashcard 46: What is a parameter's role in a procedure?

Answer: To receive arguments as input. Acts as placeholder for values passed during calls.

Flashcard 47: Identify the error: 'def foo(x, y=3, z): return x + y + z'

Answer: Non-default parameter 'z' after default 'y'. Required parameters cannot follow optional ones.

Flashcard 48: Identify the error: 'def example(a, b): return a * b; example(2)'

Answer: Missing one argument in 'example(2)'. Two parameters required but only one provided.