Email this Mix
Slide 1 - Programming Concepts
- Functions, parameters & variables
Slide 2 - Functions
- a function is a built in command that can be used in a code that references a larger chunk of code. Each programming language has it's own functions. We can "call" functions by writing them into our program.
- Real World Example: a line dance caller may tell dancers to “do-si-do”. Since the dancers already know this dance move, just calling the function “do-si-do” will result in that sequence of moves.
Slide 3 - Calling a function in Scratch:
Slide 4 - Functions with parameters
- parameters are details that have to be written with the function in order to tell the function how to run (like time or numbers).
- Real World Example: a soccer coach may tell her players to run laps by calling: “laps, 5 times”. The players know the function “laps” but require a parameter to tell them how many before they start.
Slide 5 - Defining parameters for a function in Scratch:
Slide 6 - Variables
- variables are parameters that can be changed later in the program without recalling the function
- Real World Example: a music teacher may tell a choir that they are singing Silent Night. When the choir asks for the pace she says, “watch”. The music teacher can then change the pace any time in the song just by conducting at a new pace. She can now change the pace (or “variable”) without stopping the song (or “function) and starting over again.
Slide 7 - Using variables in a function in Scratch: