AP Computer Science Principles Flashcards: Developing Procedures

Study Developing 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

Developing Procedures

0 mastered0 still learning

0% Complete

QUESTION
1/ 71

What is an argument in procedures?

Tap card or press Space to flip

ANSWER

Value passed to a procedure's parameter. The actual data passed to parameters when calling.

How well did you know it?

Card 1 / 71

What this deck covers

This deck focuses on Developing 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 an argument in procedures?

Answer: Value passed to a procedure's parameter. The actual data passed to parameters when calling.

Flashcard 2: What is a callback function?

Answer: A function passed as an argument. Used for event handling and asynchronous programming.

Flashcard 3: Identify the issue: result = multiply(2, 3) print(result)

Answer: No issue; syntax is correct. Valid code that calls function and prints result.

Flashcard 4: What is the difference between 'return' and 'print'?

Answer: 'return' outputs from a function; 'print' displays. Return sends values; print shows text on screen.

Flashcard 5: Find the syntax error: def add(a, b): return a + b

Answer: No error; syntax is correct. Valid Python function syntax with proper colon and return.

Flashcard 6: What is a lambda function?

Answer: An anonymous, inline function. Concise way to create simple functions inline.

Flashcard 7: State the term for the code block inside a procedure.

Answer: Procedure body. The executable code that implements the procedure's logic.

Flashcard 8: What is a return value in a procedure?

Answer: The output a procedure produces. The result sent back to the calling code.

Flashcard 9: State the purpose of the 'pass' statement in Python.

Answer: Placeholder for future code. Prevents syntax errors in incomplete code blocks.

Flashcard 10: What is the purpose of a procedure in programming?

Answer: Encapsulate code for reuse and modularity. Breaks complex programs into manageable, reusable components.

Flashcard 11: What is the term for a procedure without parameters?

Answer: Parameterless procedure. Takes no input values when called.

Flashcard 12: What is a procedure's signature?

Answer: Its name, parameters, and return type. Defines how to call and use the procedure.

Flashcard 13: Which keyword specifies a procedure's output in Python?

Answer: return. Sends a value back to the caller and exits the function.

Flashcard 14: Identify the error: def hello(name) print('Hello, ' + name)

Answer: Missing colon after parameters. Function definitions require colon after parameter list.

Flashcard 15: Find the error: def subtract(a, b): print(a - b) return

Answer: No error; syntax is correct. Valid procedure with side effect and empty return.

Flashcard 16: Identify the keyword used to define a procedure in Python.

Answer: def. Standard Python syntax for creating function definitions.

Flashcard 17: What is a default parameter?

Answer: A parameter with a default value. Provides fallback value when argument is not supplied.

Flashcard 18: What is an argument in procedures?

Answer: Value passed to a procedure's parameter. The actual data passed to parameters when calling.

Flashcard 19: What is a return value in a procedure?

Answer: The output a procedure produces. The result sent back to the calling code.

Flashcard 20: What is a callback function?

Answer: A function passed as an argument. Used for event handling and asynchronous programming.

Flashcard 21: What is a pure function?

Answer: A function with no side effects. Predictable behavior with no external state changes.

Flashcard 22: What is a pure function?

Answer: A function with no side effects. Predictable behavior with no external state changes.

Flashcard 23: What is a procedure's signature?

Answer: Its name, parameters, and return type. Defines how to call and use the procedure.

Flashcard 24: State the term for the code block inside a procedure.

Answer: Procedure body. The executable code that implements the procedure's logic.

Flashcard 25: Identify the error: def greet(): print('Hello') return

Answer: No error; syntax is correct. Valid syntax for procedure with print side effect.

Flashcard 26: What is the base case in recursion?

Answer: The condition to stop recursion. Prevents infinite recursion by providing an exit condition.

Flashcard 27: What is a lambda function?

Answer: An anonymous, inline function. Concise way to create simple functions inline.

Flashcard 28: Identify the error: def divide(a, b): return a / b

Answer: No error; syntax is correct. Valid division function with proper return statement.

Flashcard 29: State the term for input values a procedure uses.

Answer: Parameters. Variables that accept data when the procedure is called.

Flashcard 30: Find the error: def subtract(a, b): print(a - b) return

Answer: No error; syntax is correct. Valid procedure with side effect and empty return.

Flashcard 31: Choose the correct type: procedure vs. method

Answer: Method: Bound to an object; Procedure: Not bound. Methods belong to classes; procedures are independent.

Flashcard 32: Identify the error: def hello(name) print('Hello, ' + name)

Answer: Missing colon after parameters. Function definitions require colon after parameter list.

Flashcard 33: What does 'def' stand for in Python?

Answer: Define a procedure. Short for 'definition' in function declarations.

Flashcard 34: Choose the correct type: procedure vs. method

Answer: Method: Bound to an object; Procedure: Not bound. Methods belong to classes; procedures are independent.

Flashcard 35: Find the syntax error: def add(a, b): return a + b

Answer: No error; syntax is correct. Valid Python function syntax with proper colon and return.

Flashcard 36: What is a procedure's precondition?

Answer: Conditions assumed true before execution. Requirements that must be met before calling.

Flashcard 37: What is a procedure's name?

Answer: Identifier used to invoke it. Label that distinguishes it from other procedures.

Flashcard 38: What is the base case in recursion?

Answer: The condition to stop recursion. Prevents infinite recursion by providing an exit condition.

Flashcard 39: What is a procedure's postcondition?

Answer: Conditions ensured after execution. Guarantees about the procedure's results or effects.

Flashcard 40: Identify the error: def increment(x): x += 1 return x

Answer: No error; syntax is correct. Valid function that modifies and returns parameter.

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

Answer: Procedure invocation. The act of running or calling a procedure.

Flashcard 42: Identify the error: def multiply(a, b) return a * b

Answer: Missing colon after parameters. Python requires colon after parameter list in function definitions.

Flashcard 43: What is a procedure's name?

Answer: Identifier used to invoke it. Label that distinguishes it from other procedures.

Flashcard 44: What is a side effect in procedures?

Answer: An impact beyond returning a value. Changes program state beyond the return value.

Flashcard 45: What is the term for a procedure without parameters?

Answer: Parameterless procedure. Takes no input values when called.

Flashcard 46: State the term for a procedure that calls itself.

Answer: Recursive procedure. Uses divide-and-conquer by breaking problems into smaller parts.

Flashcard 47: Identify the keyword used to define a procedure in Python.

Answer: def. Standard Python syntax for creating function definitions.

Flashcard 48: Choose the correct usage: procedure vs. function

Answer: Procedure: No return; Function: Returns value. Functions return values; procedures perform actions.

Flashcard 49: What is the purpose of a procedure in programming?

Answer: Encapsulate code for reuse and modularity. Breaks complex programs into manageable, reusable components.

Flashcard 50: Identify the error: def sum(a, b = 5, c)

Answer: Default parameter must be last. Default parameters must come after required parameters.

Flashcard 51: What is a procedure's postcondition?

Answer: Conditions ensured after execution. Guarantees about the procedure's results or effects.

Flashcard 52: What is a default parameter?

Answer: A parameter with a default value. Provides fallback value when argument is not supplied.

Flashcard 53: State the term for input values a procedure uses.

Answer: Parameters. Variables that accept data when the procedure is called.

Flashcard 54: What is a side effect in procedures?

Answer: An impact beyond returning a value. Changes program state beyond the return value.

Flashcard 55: Identify the error: def increment(x): x += 1 return x

Answer: No error; syntax is correct. Valid function that modifies and returns parameter.

Flashcard 56: What is a procedure's precondition?

Answer: Conditions assumed true before execution. Requirements that must be met before calling.

Flashcard 57: Identify the error: def greet(): print('Hello') return

Answer: No error; syntax is correct. Valid syntax for procedure with print side effect.

Flashcard 58: Identify the error: def sum(a, b = 5, c)

Answer: Default parameter must be last. Default parameters must come after required parameters.

Flashcard 59: State the principle of DRY in programming.

Answer: Do not repeat yourself. Promotes code reuse by avoiding duplicate implementations.

Flashcard 60: Identify the error: def multiply(a, b) return a * b

Answer: Missing colon after parameters. Python requires colon after parameter list in function definitions.

Flashcard 61: State the purpose of the 'pass' statement in Python.

Answer: Placeholder for future code. Prevents syntax errors in incomplete code blocks.

Flashcard 62: Which keyword specifies a procedure's output in Python?

Answer: return. Sends a value back to the caller and exits the function.

Flashcard 63: State the term for a procedure that calls itself.

Answer: Recursive procedure. Uses divide-and-conquer by breaking problems into smaller parts.

Flashcard 64: Identify the error: def divide(a, b): return a / b

Answer: No error; syntax is correct. Valid division function with proper return statement.

Flashcard 65: Identify the issue: result = multiply(2, 3) print(result)

Answer: No issue; syntax is correct. Valid code that calls function and prints result.

Flashcard 66: Choose the correct usage: procedure vs. function

Answer: Procedure: No return; Function: Returns value. Functions return values; procedures perform actions.

Flashcard 67: State the principle of DRY in programming.

Answer: Do not repeat yourself. Promotes code reuse by avoiding duplicate implementations.

Flashcard 68: Find the error in this procedure call: add(2, )

Answer: Missing second argument. Function expects two arguments but only receives one.

Flashcard 69: What does 'def' stand for in Python?

Answer: Define a procedure. Short for 'definition' in function declarations.

Flashcard 70: What is the difference between 'return' and 'print'?

Answer: 'return' outputs from a function; 'print' displays. Return sends values; print shows text on screen.

Flashcard 71: Find the error in this procedure call: add(2, )

Answer: Missing second argument. Function expects two arguments but only receives one.