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)
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.
Functions with parameters and return values help us simplify our code
Functions can only return one value at a time
A function can have:
No parameters and no return values
Parameters, but no return values
Return values, but no parameters
Parameters and return values
Students work with envelopes and paper to model functions with parameters and return values. Students create their own physical function envelope for drawing a house that takes in different parameters, and then build another function to calculate and return the cost of building that house.
In this Explore lesson, students follow a presentation and use manipulatives to understand the basics of creating a function with parameters and return values.
CSP Conceptual Framework
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.B - For procedure calls: a. Write statements to call procedures. b. Determine the result or effect of a procedure call.
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.