All flashcards
Flashcard 1: What is a function signature?
Answer: Function name and parameter list. Identifies the procedure and its expected inputs.
Flashcard 2: What is the term for executing a procedure?
Answer: Calling a procedure. Invokes the procedure to run its code.
Flashcard 3: What is a method in object-oriented programming?
Answer: A procedure associated with a class/object. Function bound to a specific class instance.
Flashcard 4: What is a procedure in programming?
Answer: A named section of code that performs a specific task. Code blocks enable reusability and modularity.
Flashcard 5: Identify the part of a procedure that specifies input.
Answer: Parameters. Parameters define what inputs the procedure expects.
Flashcard 6: 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 7: What is returned if a procedure lacks a return statement?
Answer: Typically, 'None' or equivalent. Default return when no explicit return statement exists.
Flashcard 8: 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 9: How are procedures beneficial in programming?
Answer: They promote code reuse and organization. Avoid code duplication and improve maintainability.
Flashcard 10: Which part of a procedure specifies its output?
Answer: Return value. What the procedure sends back to the caller.
Flashcard 11: What is a parameter's role in a procedure?
Answer: To receive arguments as input. Acts as placeholder for values passed during calls.
Flashcard 12: What does 'pass by value' mean?
Answer: Arguments are copied into parameters. Original values remain unchanged in calling code.
Flashcard 13: What does 'pass by reference' mean?
Answer: Parameters refer to argument locations. Changes to parameters affect original variables.
Flashcard 14: Choose the correct term: 'void' procedures return a value?
Answer: False. Void procedures perform actions without returning values.
Flashcard 15: Find the error: 'def greet(name): return print('Hello', name)'
Answer: Remove 'return' before 'print'. Cannot return a function call that returns None.
Flashcard 16: What is recursion in procedures?
Answer: Procedure calls itself. Enables solving problems by breaking them down.
Flashcard 17: What is modularity in programming?
Answer: Dividing a program into separate modules. Breaks complex problems into manageable components.
Flashcard 18: 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 19: What is the scope of a parameter?
Answer: Within the procedure where it is defined. Parameters only exist within their procedure's execution.
Flashcard 20: State whether procedures can have default parameter values.
Answer: Yes. Default values provide flexibility in procedure calls.
Flashcard 21: 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 22: What does 'pass by reference' mean?
Answer: Parameters refer to argument locations. Changes to parameters affect original variables.
Flashcard 23: Identify the part of a procedure that specifies input.
Answer: Parameters. Parameters define what inputs the procedure expects.
Flashcard 24: Find the error: 'def greet(name): return print('Hello', name)'
Answer: Remove 'return' before 'print'. Cannot return a function call that returns None.
Flashcard 25: How are procedures beneficial in programming?
Answer: They promote code reuse and organization. Avoid code duplication and improve maintainability.
Flashcard 26: What is modularity in programming?
Answer: Dividing a program into separate modules. Breaks complex problems into manageable components.
Flashcard 27: What is a procedure in programming?
Answer: A named section of code that performs a specific task. Code blocks enable reusability and modularity.
Flashcard 28: 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 29: What is a parameter's role in a procedure?
Answer: To receive arguments as input. Acts as placeholder for values passed during calls.
Flashcard 30: Which part of a procedure specifies its output?
Answer: Return value. What the procedure sends back to the caller.