Tying your shoes is an example of a function. It takes many steps, but once we know all the steps, we just think about the whole process as one function. This concept helps coders. They only have to write the steps of a task once and wrap it in a function to use later.
Variables can be named anything by the coder. If you’re keeping track of the basketball score you could name the variables ‘a’ and ‘b’. This would get confusing, though, as it isn’t clear by the names what they are. A better name for the variables would be HomeTeamScore and AwayTeamScore. The values in the variables would be the number of points each team has.
Select an activity below to download the PDF.
Have you ever made or ordered a pizza? What variables or ingredients did you pick? What variable tastes the best?
Have you read other books about functions or variables? What did you learn?
Have you ever grown a plant? What variables do you think farmers need to grow something? Does the location of the farm change the variable?