Calling Procedures - AP Computer Science Principles
Card 1 of 30
What is a function signature?
What is a function signature?
Tap to reveal answer
Function name and parameter list. Identifies the procedure and its expected inputs.
Function name and parameter list. Identifies the procedure and its expected inputs.
← Didn't Know|Knew It →
What is the term for executing a procedure?
What is the term for executing a procedure?
Tap to reveal answer
Calling a procedure. Invokes the procedure to run its code.
Calling a procedure. Invokes the procedure to run its code.
← Didn't Know|Knew It →
What is a method in object-oriented programming?
What is a method in object-oriented programming?
Tap to reveal answer
A procedure associated with a class/object. Function bound to a specific class instance.
A procedure associated with a class/object. Function bound to a specific class instance.
← Didn't Know|Knew It →
What is a procedure in programming?
What is a procedure in programming?
Tap to reveal answer
A named section of code that performs a specific task. Code blocks enable reusability and modularity.
A named section of code that performs a specific task. Code blocks enable reusability and modularity.
← Didn't Know|Knew It →
Identify the part of a procedure that specifies input.
Identify the part of a procedure that specifies input.
Tap to reveal answer
Parameters. Parameters define what inputs the procedure expects.
Parameters. Parameters define what inputs the procedure expects.
← Didn't Know|Knew It →
Find and correct the error: 'def myFunc(x, y) return x + y'
Find and correct the error: 'def myFunc(x, y) return x + y'
Tap to reveal answer
Correct: 'def myFunc(x, y): return x + y'. Missing colon after parameter list in function definition.
Correct: 'def myFunc(x, y): return x + y'. Missing colon after parameter list in function definition.
← Didn't Know|Knew It →
What is returned if a procedure lacks a return statement?
What is returned if a procedure lacks a return statement?
Tap to reveal answer
Typically, 'None' or equivalent. Default return when no explicit return statement exists.
Typically, 'None' or equivalent. Default return when no explicit return statement exists.
← Didn't Know|Knew It →
Identify the error: 'def add(a, b): print(a + b)' when expecting return.
Identify the error: 'def add(a, b): print(a + b)' when expecting return.
Tap to reveal answer
Missing return statement. Function prints but doesn't return the sum value.
Missing return statement. Function prints but doesn't return the sum value.
← Didn't Know|Knew It →
How are procedures beneficial in programming?
How are procedures beneficial in programming?
Tap to reveal answer
They promote code reuse and organization. Avoid code duplication and improve maintainability.
They promote code reuse and organization. Avoid code duplication and improve maintainability.
← Didn't Know|Knew It →
Which part of a procedure specifies its output?
Which part of a procedure specifies its output?
Tap to reveal answer
Return value. What the procedure sends back to the caller.
Return value. What the procedure sends back to the caller.
← Didn't Know|Knew It →
What is a parameter's role in a procedure?
What is a parameter's role in a procedure?
Tap to reveal answer
To receive arguments as input. Acts as placeholder for values passed during calls.
To receive arguments as input. Acts as placeholder for values passed during calls.
← Didn't Know|Knew It →
What does 'pass by value' mean?
What does 'pass by value' mean?
Tap to reveal answer
Arguments are copied into parameters. Original values remain unchanged in calling code.
Arguments are copied into parameters. Original values remain unchanged in calling code.
← Didn't Know|Knew It →
What does 'pass by reference' mean?
What does 'pass by reference' mean?
Tap to reveal answer
Parameters refer to argument locations. Changes to parameters affect original variables.
Parameters refer to argument locations. Changes to parameters affect original variables.
← Didn't Know|Knew It →
Choose the correct term: 'void' procedures return a value?
Choose the correct term: 'void' procedures return a value?
Tap to reveal answer
False. Void procedures perform actions without returning values.
False. Void procedures perform actions without returning values.
← Didn't Know|Knew It →
Find the error: 'def greet(name): return print('Hello', name)'
Find the error: 'def greet(name): return print('Hello', name)'
Tap to reveal answer
Remove 'return' before 'print'. Cannot return a function call that returns None.
Remove 'return' before 'print'. Cannot return a function call that returns None.
← Didn't Know|Knew It →
What is recursion in procedures?
What is recursion in procedures?
Tap to reveal answer
Procedure calls itself. Enables solving problems by breaking them down.
Procedure calls itself. Enables solving problems by breaking them down.
← Didn't Know|Knew It →
What is modularity in programming?
What is modularity in programming?
Tap to reveal answer
Dividing a program into separate modules. Breaks complex problems into manageable components.
Dividing a program into separate modules. Breaks complex problems into manageable components.
← Didn't Know|Knew It →
Identify the error in: 'def add(x, y): return x + y; print(add(3))'
Identify the error in: 'def add(x, y): return x + y; print(add(3))'
Tap to reveal answer
Missing one argument in 'add(3)'. Function expects two arguments but only receives one.
Missing one argument in 'add(3)'. Function expects two arguments but only receives one.
← Didn't Know|Knew It →
What is the scope of a parameter?
What is the scope of a parameter?
Tap to reveal answer
Within the procedure where it is defined. Parameters only exist within their procedure's execution.
Within the procedure where it is defined. Parameters only exist within their procedure's execution.
← Didn't Know|Knew It →
State whether procedures can have default parameter values.
State whether procedures can have default parameter values.
Tap to reveal answer
Yes. Default values provide flexibility in procedure calls.
Yes. Default values provide flexibility in procedure calls.
← Didn't Know|Knew It →
Identify the error: 'def func(x=1, y): return x + y'
Identify the error: 'def func(x=1, y): return x + y'
Tap to reveal answer
Non-default parameter 'y' after default 'x'. Required parameters must come before defaults.
Non-default parameter 'y' after default 'x'. Required parameters must come before defaults.
← Didn't Know|Knew It →
What does 'pass by reference' mean?
What does 'pass by reference' mean?
Tap to reveal answer
Parameters refer to argument locations. Changes to parameters affect original variables.
Parameters refer to argument locations. Changes to parameters affect original variables.
← Didn't Know|Knew It →
Identify the part of a procedure that specifies input.
Identify the part of a procedure that specifies input.
Tap to reveal answer
Parameters. Parameters define what inputs the procedure expects.
Parameters. Parameters define what inputs the procedure expects.
← Didn't Know|Knew It →
Find the error: 'def greet(name): return print('Hello', name)'
Find the error: 'def greet(name): return print('Hello', name)'
Tap to reveal answer
Remove 'return' before 'print'. Cannot return a function call that returns None.
Remove 'return' before 'print'. Cannot return a function call that returns None.
← Didn't Know|Knew It →
How are procedures beneficial in programming?
How are procedures beneficial in programming?
Tap to reveal answer
They promote code reuse and organization. Avoid code duplication and improve maintainability.
They promote code reuse and organization. Avoid code duplication and improve maintainability.
← Didn't Know|Knew It →
What is modularity in programming?
What is modularity in programming?
Tap to reveal answer
Dividing a program into separate modules. Breaks complex problems into manageable components.
Dividing a program into separate modules. Breaks complex problems into manageable components.
← Didn't Know|Knew It →
What is a procedure in programming?
What is a procedure in programming?
Tap to reveal answer
A named section of code that performs a specific task. Code blocks enable reusability and modularity.
A named section of code that performs a specific task. Code blocks enable reusability and modularity.
← Didn't Know|Knew It →
Identify the error: 'def add(a, b): print(a + b)' when expecting return.
Identify the error: 'def add(a, b): print(a + b)' when expecting return.
Tap to reveal answer
Missing return statement. Function prints but doesn't return the sum value.
Missing return statement. Function prints but doesn't return the sum value.
← Didn't Know|Knew It →
What is a parameter's role in a procedure?
What is a parameter's role in a procedure?
Tap to reveal answer
To receive arguments as input. Acts as placeholder for values passed during calls.
To receive arguments as input. Acts as placeholder for values passed during calls.
← Didn't Know|Knew It →
Which part of a procedure specifies its output?
Which part of a procedure specifies its output?
Tap to reveal answer
Return value. What the procedure sends back to the caller.
Return value. What the procedure sends back to the caller.
← Didn't Know|Knew It →