NOTE: As of December, site content associated with Google accounts has been blocked by the DCPS Technology system. For that reason, more up-to-date information can be found in my TEAMS channels for the remainder of the school year.
Warm Up (5 minutes)
Activity (30 minutes)
Wrap Up (10 minutes)
Lesson Slides
Parameter: a variable in a function definition. Used as a placeholder for values that will be passed through the function.
Argument: the value passed to the parameter
Return: used to return the flow of control to the point where the procedure (also known as a function) was called and to return the value of expression.
Return Total:
It stops the flow of the function. If a return is inside of a conditional, if that condition is met the function ends there.
It returns a value to the place where the function was called.
Extracting shared features to generalize functionality is known as procedural abstraction.
Using parameters allows the functions (also called procedures) to be generalized.
Using procedural abstraction helps improve code readability.
Procedural abstraction manages complexity by allowing for code reuse.
For example: the function move(id, direction) could be used to move an element in any direction, rather than writing separate functions for each direction.
Students practice writing programs with parameters and return values by creating and debugging functions that use them.
This is students' opportunity to practice using parameters and return values in a variety of contexts. The progression of levels builds in complexity from students merely calling functions with parameters to designing functions and debugging complex programs that use parameters and return values. This lesson should build students familiarity with these concepts as they prepare for the Make project in the next lesson.
CSP Conceptual Framework
AAP-2 - The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.
AAP-2.C - Evaluate expressions that use arithmetic operators.
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
AAP-3 - Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing programmers to write programs more quickly and with more confidence.
AAP-3.A - For procedure calls: a. Write statements to call procedures. b. Determine the result or effect of a procedure call.
AAP-3.C - Develop procedural abstractions to manage complexity in a program by writing procedures.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
2-AP-14 - Create procedures with parameters to organize code and make it easier to reuse.